Skip to content

Commit

Permalink
Fix density default value (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav authored Aug 31, 2024
1 parent 7be7b71 commit bc219fd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Source/ProceduralPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ProceduralPart : PartModule, IPartCostModifier, IPartMassModifier

[KSPField(isPersistant = true, guiActiveEditor = false, guiName = "Stringer Mass", groupName = PAWGroupName, groupDisplayName = PAWGroupDisplayName)]
[UI_FloatRange(minValue = 0f, maxValue = 1.0f, stepIncrement = 0.01f)]
public float density = 0;
public float density = -1;
public const float NominalDensity = 0.15f;
[KSPField] public float minDensity = 0f;
[KSPField] public float maxDensity = 0f;
Expand Down Expand Up @@ -78,8 +78,6 @@ public override void OnLoad(ConfigNode node)
// An existing vessel part or .craft file that has never set this value before, but not the availablePart
if (HighLogic.LoadedScene != GameScenes.LOADING && !node.HasValue(nameof(forceLegacyTextures)))
forceLegacyTextures = true;

SetPFFields();
}

public override string GetInfo()
Expand Down Expand Up @@ -159,11 +157,11 @@ public override void OnStart(StartState state)
opt.onFieldChanged = OnShapeSelectionChanged;

Fields[nameof(costDisplay)].guiActiveEditor = displayCost;
SetPFFields();

GameEvents.onVariantApplied.Add(OnVariantApplied);
GameEvents.onGameSceneSwitchRequested.Add(OnEditorExit);
}
SetPFFields();

// Done here and done in OnStartFinished in TankContentSwitcher to get ordering right
// since these get fired in reverse-add order
Expand Down Expand Up @@ -665,6 +663,9 @@ private void SetPFFields()
{
fieldDensity.guiActiveEditor = false;
}

if (density < 0f)
density = Math.Max(minDensity, 0f);
}

private void OnShipModified(ShipConstruct _)
Expand Down

0 comments on commit bc219fd

Please sign in to comment.