private void _applyModSettings() { foreach (var o in GameObject.FindObjectsOfType <GameObject>().Where(e => e.GetComponent <CrossingBehaviour>() != null)) { o.GetComponent <CrossingBehaviour>().UpdateSettings((bool)EnableSound.GetValue(), (bool)EnableBarrier.GetValue(), (bool)Breakable.GetValue()); } foreach (var o in GameObject.FindObjectsOfType <GameObject>().Where(e => e.GetComponent <CrossingTriggerBehaviour>() != null)) { o.GetComponent <Renderer>().enabled = (bool)ShowTriggers.GetValue(); o.GetComponent <CrossingTriggerBehaviour>().Verbose = (bool)Verbose.GetValue(); } }
/// <summary> /// Save a game to disk. /// </summary> /// <param name="filename">Name of the file to use for storing the game.</param> /// <returns>The game was saved successfully.</returns> public bool SaveFile(string filename) { long n; if (!File.Exists(filename)) { return(false); } /* total funds is a long..... miscHist is array of ints */ /* total funds is bien put in the 50th & 51th word of miscHist */ /* find the address, cast the ptr to a longPtr, take contents */ saveIntToShort(MiscHist, 50, (int)TotalFunds); saveIntToShort(MiscHist, 50, (int)CityTime); MiscHist[52] = AutoBulldoze.ToShort(); // flag for autoBulldoze MiscHist[53] = AutoBudget.ToShort(); // flag for autoBudget MiscHist[54] = AutoGoTo.ToShort(); // flag for auto-goto MiscHist[55] = EnableSound.ToShort(); // flag for the sound on/off MiscHist[57] = SimSpeed; MiscHist[56] = (short)CityTax; /* post release */ /* yayaya */ saveIntToShort(MiscHist, 58, (int)PolicePercentage); saveIntToShort(MiscHist, 60, (int)FirePercentage); saveIntToShort(MiscHist, 62, (int)RoadPercentage); bool result = true; using (BinaryWriter f = new BinaryWriter(File.OpenWrite(filename))) { result = result && saveShorts(ResHist, f) && saveShorts(ComHist, f) && saveShorts(IndHist, f) && saveShorts(CrimeHist, f) && saveShorts(PollutionHist, f) && saveShorts(MoneyHist, f) && saveShorts(MiscHist, f); for (int x = 0; x < Constants.WorldWidth; ++x) { for (int y = 0; y < Constants.WorldHeight; ++y) { result = result && saveShort((short)Map[x, y], f); } } } return(result); }