Skip to content

Commit

Permalink
Another fix to maintenance costs, changed first level pad to be lvl 1…
Browse files Browse the repository at this point in the history
… instead of 0
siimav committed Jan 16, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 3683f08 commit 819d459
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/Maintenance/MaintenanceGUI.cs
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ public void facilitiesTab()
continue;
GUILayout.BeginHorizontal();
try {
GUILayout.Label(String.Format(" level {0} × {1}", i, MaintenanceHandler.Instance.kctPadCounts[i]), HighLogic.Skin.label, GUILayout.Width(160));
GUILayout.Label(String.Format(" level {0} × {1}", i + 1, MaintenanceHandler.Instance.kctPadCounts[i]), HighLogic.Skin.label, GUILayout.Width(160));
GUILayout.Label((MaintenanceHandler.Instance.padCosts[i] * perFactor).ToString(perFormat), rightLabel, GUILayout.Width(160));
} finally {
GUILayout.EndHorizontal();
11 changes: 9 additions & 2 deletions Source/Maintenance/MaintenanceHandler.cs
Original file line number Diff line number Diff line change
@@ -99,13 +99,15 @@ public override void OnLoad(ConfigNode node)

if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
{
EnsureFacilityLvlCostsLoaded();
// Need to load the facility upgrade prices after CustomBarnKit has finished patching them
GameEvents.onLevelWasLoaded.Add(LoadUpgradesPrices);
}
}

public void updateUpkeep()
{
float[] costs;
EnsureFacilityLvlCostsLoaded();

// Pad
if (facilityLevelCosts.TryGetValue(SpaceCenterFacility.LaunchPad, out costs))
@@ -197,7 +199,6 @@ public void Update()
return;
}

EnsureFacilityLvlCostsLoaded();
updateUpkeep();

double timePassed = time - lastUpdate;
@@ -243,5 +244,11 @@ private void EnsureFacilityLvlCostsLoaded()
Debug.Log($"[RP-0] Updated facilityLevelsCosts, count: {facilityLevelCosts.Count}");
}
}

private void LoadUpgradesPrices(GameScenes scene)
{
EnsureFacilityLvlCostsLoaded();
GameEvents.onLevelWasLoaded.Remove(LoadUpgradesPrices);
}
}
}

0 comments on commit 819d459

Please sign in to comment.