// Thread: Main public override void OnRefreshMilestones() { if (Singleton <SimulationManager> .instance.m_metaData.m_updateMode == SimulationManager.UpdateMode.NewGame) { // only do once if (!unlockedAreas) { IAreas AreasManager = Managers.areas; // calculate original cash long originalCash = EconomyManager.instance.InternalCashAmount; // causes rendering issue in new areas Singleton <UnlockManager> .instance.UnlockAllProgressionMilestones(); // unlock all tiles int rows = (int)Math.Sqrt(AreasManager.maxAreaCount); for (int x = 0; x < rows; x++) { for (int y = 0; y < rows; y++) { int column = x; int row = y; if (rows.Equals(3)) { column = x + 1; row = y + 1; } if (!AreasManager.IsAreaUnlocked(column, row) && AreasManager.CanUnlockArea(column, row)) { AreasManager.UnlockArea(column, row, false); } } } // copy milestone info so we can reset it to default MilestoneInfo[] MilestoneInfos = new MilestoneInfo[UnlockManager.instance.m_allMilestones.Count]; UnlockManager.instance.m_allMilestones.Values.CopyTo(MilestoneInfos, 0); UnlockManager.ResetMilestones(MilestoneInfos, false); // calculated added cash long finalCash = EconomyManager.instance.InternalCashAmount; int cashDifference = Convert.ToInt32(originalCash - finalCash); // remove cash difference EconomyManager.instance.AddResource(EconomyManager.Resource.LoanAmount, cashDifference, ItemClass.Service.None, ItemClass.SubService.None, ItemClass.Level.None); } } unlockedAreas = true; }
public override void OnUnlockArea(int x, int z) { // define variables to keep track of which area is still locked int lockedX = -1; int lockedZ = -1; bool foundLockedArea = false; // first, do what this function is meant to do and continue unlocking area x,z base.OnUnlockArea(x, z); // next, search for another area which is still locked // (note that we purposely don't want to unlock all remaining areas at once inside the loop - we'll unlock one new area for each call to this function) if (myAreas.unlockedAreaCount < myAreas.maxAreaCount) { for (int ix = 0; ix < MaxAreaX; ix++) { for (int iz = 0; iz < MaxAreaZ; iz++) { // if we find a locked area, save the info so that we can unlock it if (myAreas.CanUnlockArea(ix, iz)) { lockedX = ix; lockedZ = iz; foundLockedArea = true; } } } } // if we found a locked area, unlock it if (foundLockedArea) { // note that unlocking this area will call this function again; on the next call we'll unlock another area and keep recursing one area at a time until all areas are unlocked myAreas.UnlockArea(lockedX, lockedZ, false); } }