diff --git a/TestFlightContracts/TestFlightContractConfigurator.cs b/TestFlightContracts/TestFlightContractConfigurator.cs index 3ceff57..28dd7a4 100644 --- a/TestFlightContracts/TestFlightContractConfigurator.cs +++ b/TestFlightContracts/TestFlightContractConfigurator.cs @@ -82,13 +82,13 @@ protected override void OnParameterLoad(ConfigNode node) protected override void OnRegister() { base.OnRegister(); - GameEvents.Contract.onAccepted.Add(new EventData.OnEvent(OnContractAccepted)); + GameEvents.Contract.onAccepted.Add(OnContractAccepted); } protected override void OnUnregister() { base.OnUnregister(); - GameEvents.Contract.onAccepted.Remove(new EventData.OnEvent(OnContractAccepted)); + GameEvents.Contract.onAccepted.Remove(OnContractAccepted); } protected void OnContractAccepted(Contract contract) diff --git a/TestFlightCore/TestFlightCore/TestFlight.cs b/TestFlightCore/TestFlightCore/TestFlight.cs index c49cf4c..c6c9edc 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/TestFlightCore.cs b/TestFlightCore/TestFlightCore/TestFlightCore.cs index cf5eedb..786276f 100644 --- a/TestFlightCore/TestFlightCore/TestFlightCore.cs +++ b/TestFlightCore/TestFlightCore/TestFlightCore.cs @@ -803,11 +803,8 @@ public override void Start() public override void OnDestroy() { base.OnDestroy(); - if (HighLogic.LoadedSceneIsFlight) - { - GameEvents.onCrewTransferred.Remove(OnCrewChange); - GameEvents.onStageActivate.Remove(OnStageActivate); - } + GameEvents.onCrewTransferred.Remove(OnCrewChange); + GameEvents.onStageActivate.Remove(OnStageActivate); } public override void OnAwake() diff --git a/TestFlightCore/TestFlightCore/TestFlightKSC.cs b/TestFlightCore/TestFlightCore/TestFlightKSC.cs index 561505b..90885f1 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 01c40eb..f8c5429 100644 --- a/TestFlightCore/TestFlightCore/TestFlightRnD.cs +++ b/TestFlightCore/TestFlightCore/TestFlightRnD.cs @@ -13,14 +13,17 @@ namespace TestFlightCore public class TestFlightRnD : MonoBehaviour { Dictionary baseCost = null; + public void Start() { - RDController.OnRDTreeSpawn.Add(new EventData.OnEvent(OnTreeSpawn)); + RDController.OnRDTreeSpawn.Add(OnTreeSpawn); DontDestroyOnLoad(this); } + public void OnTreeSpawn(RDController controller) { - if (TestFlightManagerScenario.Instance == null || controller.nodes == null) + if (TestFlightManagerScenario.Instance == null || controller.nodes == null || + !TestFlightManagerScenario.Instance.SettingsTechDiscountEnabled) { return; }