Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav committed Apr 9, 2023
2 parents 1a90c52 + 83691b0 commit 85a4900
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions TestFlightContracts/TestFlightContractConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ protected override void OnParameterLoad(ConfigNode node)
protected override void OnRegister()
{
base.OnRegister();
GameEvents.Contract.onAccepted.Add(new EventData<Contract>.OnEvent(OnContractAccepted));
GameEvents.Contract.onAccepted.Add(OnContractAccepted);
}

protected override void OnUnregister()
{
base.OnUnregister();
GameEvents.Contract.onAccepted.Remove(new EventData<Contract>.OnEvent(OnContractAccepted));
GameEvents.Contract.onAccepted.Remove(OnContractAccepted);
}

protected void OnContractAccepted(Contract contract)
Expand Down
2 changes: 2 additions & 0 deletions TestFlightCore/TestFlightCore/TestFlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions TestFlightCore/TestFlightCore/TestFlightCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions TestFlightCore/TestFlightCore/TestFlightKSC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions TestFlightCore/TestFlightCore/TestFlightRnD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ namespace TestFlightCore
public class TestFlightRnD : MonoBehaviour
{
Dictionary<string, int> baseCost = null;

public void Start()
{
RDController.OnRDTreeSpawn.Add(new EventData<RDController>.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;
}
Expand Down

0 comments on commit 85a4900

Please sign in to comment.