From 01665fbdf4e08669c7a41c5051736604435125d7 Mon Sep 17 00:00:00 2001 From: siimav Date: Sat, 31 Aug 2024 03:15:02 +0300 Subject: [PATCH] Fix density default value --- Source/ProceduralPart.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/ProceduralPart.cs b/Source/ProceduralPart.cs index aa5ebae..8c5428c 100644 --- a/Source/ProceduralPart.cs +++ b/Source/ProceduralPart.cs @@ -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; @@ -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() @@ -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 @@ -665,6 +663,9 @@ private void SetPFFields() { fieldDensity.guiActiveEditor = false; } + + if (density < 0f) + density = Math.Max(minDensity, 0f); } private void OnShipModified(ShipConstruct _)