From 83691b0239c1e6936a2982f7c2d34e22a0739050 Mon Sep 17 00:00:00 2001 From: siimav Date: Sun, 9 Apr 2023 00:00:03 +0300 Subject: [PATCH] Add setting for tech node discount --- TestFlightCore/TestFlightCore/TestFlight.cs | 2 ++ TestFlightCore/TestFlightCore/TestFlightKSC.cs | 7 +++++++ TestFlightCore/TestFlightCore/TestFlightRnD.cs | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/TestFlightCore/TestFlightCore/TestFlight.cs b/TestFlightCore/TestFlightCore/TestFlight.cs index c49cf4cc..c6c9edc8 100644 --- a/TestFlightCore/TestFlightCore/TestFlight.cs +++ b/TestFlightCore/TestFlightCore/TestFlight.cs @@ -405,8 +405,10 @@ public class TestFlightManagerScenario : ScenarioModule [KSPField(isPersistant = true)] public bool settingsEnabled = true; [KSPField(isPersistant = true)] public bool settingsAlwaysMaxData = false; + [KSPField(isPersistant = true)] public bool settingsTechDiscountEnabled = false; public bool SettingsEnabled { get { return settingsEnabled; } set { settingsEnabled = value; } } public bool SettingsAlwaysMaxData { get { return settingsAlwaysMaxData; } set { settingsAlwaysMaxData = value; } } + public bool SettingsTechDiscountEnabled { get { return settingsTechDiscountEnabled; } set { settingsTechDiscountEnabled = value; } } private bool rp1Available = false; private bool careerLogging = false; diff --git a/TestFlightCore/TestFlightCore/TestFlightKSC.cs b/TestFlightCore/TestFlightCore/TestFlightKSC.cs index 561505b9..90885f1c 100644 --- a/TestFlightCore/TestFlightCore/TestFlightKSC.cs +++ b/TestFlightCore/TestFlightCore/TestFlightKSC.cs @@ -308,6 +308,13 @@ internal override void DrawWindow(int id) tfScenario.SettingsAlwaysMaxData = saveMaxData; } GUILayout.EndHorizontal(); + GUILayout.BeginHorizontal(); + bool techDiscountEnabled = tfScenario.SettingsTechDiscountEnabled; + if (DrawToggle(ref techDiscountEnabled, "Apply discount to tech node cost for flown parts", Styles.styleToggle)) + { + tfScenario.SettingsTechDiscountEnabled = techDiscountEnabled; + } + GUILayout.EndHorizontal(); break; } break; diff --git a/TestFlightCore/TestFlightCore/TestFlightRnD.cs b/TestFlightCore/TestFlightCore/TestFlightRnD.cs index 033038c9..f8c54292 100644 --- a/TestFlightCore/TestFlightCore/TestFlightRnD.cs +++ b/TestFlightCore/TestFlightCore/TestFlightRnD.cs @@ -22,7 +22,8 @@ public void Start() public void OnTreeSpawn(RDController controller) { - if (TestFlightManagerScenario.Instance == null || controller.nodes == null) + if (TestFlightManagerScenario.Instance == null || controller.nodes == null || + !TestFlightManagerScenario.Instance.SettingsTechDiscountEnabled) { return; }