Skip to content

Commit

Permalink
v1.1.15 - I hate this game code
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbian committed Aug 16, 2017
1 parent c470d8a commit 33a84d0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
34 changes: 21 additions & 13 deletions CustomBarnKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ public void Start()
GameVariables.Instance = customGameVariables;
// Make sure the network uses the new config. I could not find an event that only update the TrackingStation
// But I guess something exist for when you update it....
CommNetNetwork.Reset();
varLoaded = true;

if (CommNetNetwork.Instance != null)
CommNetNetwork.Reset();
log(customGameVariables.ToString());

// We have to reload everything at each scene changes because the game mess up some of the values...
GameEvents.onLevelWasLoaded.Add(LoadUpgradesPrices);
}
}
Expand All @@ -42,6 +43,9 @@ public void Update()
// With the help of NoMoreGrind code by nlight
private void LoadUpgradesPrices(GameScenes data)
{
if (data == GameScenes.MAINMENU || data == GameScenes.SETTINGS || data == GameScenes.CREDITS)
return;

log("Loading new upgrades prices");

foreach (UpgradeableFacility facility in GameObject.FindObjectsOfType<UpgradeableFacility>())
Expand Down Expand Up @@ -85,25 +89,29 @@ private void LoadUpgradesPrices(GameScenes data)
level.facilityPrefab = sourceLvl.facilityPrefab;
level.facilityInstance = null;

if (levelsVisual.Length == levels)
{
//log(facility.name + " Copying level " + (levelsVisual[i] - 1) + " for level " + (i + 1));
level.facilityPrefab = upgradeLevels[levelsVisual[i] - 1].facilityPrefab;
}
else
// Only redo the visual on the first load. Doing it on the next loads would mess up the order.
if (!varLoaded)
{
log("Wrong levelsVisual length " + levelsVisual.Length + " for " + facility.name + " expected " + levels);
if (levelsVisual.Length == levels)
{
//log(facility.name + " Copying level " + (levelsVisual[i] - 1) + " for level " + (i + 1));
level.facilityPrefab = upgradeLevels[levelsVisual[i] - 1].facilityPrefab;
}
else
{
log("Wrong levelsVisual length " + levelsVisual.Length + " for " + facility.name + " expected " + levels);
}
}

newUpgradeLevels[i] = level;
}

facility.UpgradeLevels = newUpgradeLevels;
facility.SetupLevels();
facility.setLevel(facility.FacilityLevel);
}
GameEvents.onLevelWasLoaded.Remove(LoadUpgradesPrices);
//log("New upgrades prices are Loaded");
if (!varLoaded)
log("New upgrades prices are Loaded");
varLoaded = true;
}

private float[] getFacilityUpgradePrices(SpaceCenterFacility f)
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.14.0")]
[assembly: AssemblyFileVersion("1.1.14.0")]
[assembly: AssemblyVersion("1.1.15.0")]
[assembly: AssemblyFileVersion("1.1.15.0")]

0 comments on commit 33a84d0

Please sign in to comment.