/// <summary> /// Sets the customised number of households for a given prefab. /// If a record doesn't already exist, a new one will be created. /// </summary> /// <param name="prefab">The prefab (BuildingInfo) to set</param> /// <param name="houses">The updated households</param> public static void SetResidential(BuildingInfo prefab, int houses) { // Update or add entry to configuration file cache. if (DataStore.householdCache.ContainsKey(prefab.name)) { // Prefab already has a record; update. DataStore.householdCache[prefab.name] = houses; } else { // Prefab doesn't already have a record; create. DataStore.householdCache.Add(prefab.name, houses); } // Save the updated configuration file. XMLUtilsWG.WriteToXML(); // Get current building hash (for updating prefab dictionary). var prefabHash = prefab.gameObject.GetHashCode(); // Update entry in 'live' settings. if (DataStore.prefabHouseHolds.ContainsKey(prefabHash)) { // Prefab already has a record; update. DataStore.prefabHouseHolds[prefabHash] = houses; } else { // Prefab doesn't already have a record; create. DataStore.prefabHouseHolds.Add(prefabHash, houses); } }
/// <summary> /// Removes the custom household record (if any) for a given prefab. /// </summary> /// <param name="prefab">The prefab (BuildingInfo) to remove the record from</param> public static void RemoveResidential(BuildingInfo prefab) { // Remove the entry from the configuration file cache. DataStore.householdCache.Remove(prefab.name); // Save the updated configuration file. XMLUtilsWG.WriteToXML(); // Remove current building's record from 'live' dictionary. DataStore.prefabHouseHolds.Remove(prefab.gameObject.GetHashCode()); }
/// <summary> /// Removes the custom household record (if any) for a given prefab. /// </summary> /// <param name="prefab">The prefab (BuildingInfo) to remove the record from</param> public static void RemoveWorker(BuildingInfo prefab) { // Remove the entry from the configuration file cache. DataStore.workerCache.Remove(prefab.name); // Save the updated configuration file. XMLUtilsWG.WriteToXML(); // Remove current building's record from 'live' dictionary. DataStore.prefabWorkerVisit.Remove(prefab.gameObject.GetHashCode()); }
/// <summary> /// Updates the DataStore with the information from the text fields. /// </summary> protected override void ApplyFields() { // Apply each subservice. ApplySubService(DataStore.office, Office); ApplySubService(DataStore.officeHighTech, HighTech); // Clear cached values. DataStore.prefabWorkerVisit.Clear(); // Save new settings. XMLUtilsWG.WriteToXML(); // Refresh settings. PopulateFields(); }
public override void OnLevelLoaded(LoadMode mode) { // Check to see if a conflicting mod has been detected - if so, alert the user. if (conflictingMod) { UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Realistic Population Revisited", "Original Realistic Population and Consumption Mod mod detected - Realistic Population Revisited is shutting down to protect your game. Only ONE of these mods can be enabled at the same time; please unsubscribe from the old Realistic Population and Consumption Mod, which is now deprecated!", true); } // Don't do anything further if mod hasn't activated (conflicting mod detected, or loading into editor instead of game). if (!isModEnabled) { return; } else if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame) { if (!isLevelLoaded) { isLevelLoaded = true; // Now we can remove people DataStore.allowRemovalOfCitizens = true; Debugging.releaseBuffer(); Debugging.Message("successfully applied"); } } // Create new XML if one doesn't already exist. if (!File.Exists(DataStore.currentFileLocation)) { XMLUtilsWG.WriteToXML(); } // Add button to building info panels. BuildingDetailsPanel.AddInfoPanelButton(); // Check if we need to display update notification. if (UpdateNotification.notificationVersion != 2) { // No update notification "Don't show again" flag found; show the notification. UpdateNotification notification = new UpdateNotification(); notification.Create(); notification.Show(); } // Set up options panel event handler. OptionsPanel.OptionsEventHook(); }
/// <summary> /// Updates the DataStore with the information from the text fields. /// </summary> protected override void ApplyFields() { // Apply each subservice. ApplySubService(DataStore.residentialLow, LowRes); ApplySubService(DataStore.residentialHigh, HighRes); ApplySubService(DataStore.resEcoLow, LowEcoRes); ApplySubService(DataStore.resEcoHigh, HighEcoRes); // Clear cached values. DataStore.prefabHouseHolds.Clear(); // Save new settings. XMLUtilsWG.WriteToXML(); // Refresh settings. PopulateFields(); }
/// <summary> /// Updates the DataStore with the information from the text fields. /// </summary> protected override void ApplyFields() { // Apply each subservice. ApplySubService(DataStore.commercialLow, LowCom); ApplySubService(DataStore.commercialHigh, HighCom); ApplySubService(DataStore.commercialEco, EcoCom); ApplySubService(DataStore.commercialLeisure, Leisure); ApplySubService(DataStore.commercialTourist, Tourist); // Clear cached values. DataStore.prefabWorkerVisit.Clear(); // Save new settings. XMLUtilsWG.WriteToXML(); // Refresh settings. PopulateFields(); }
/// <summary> /// Updates the DataStore with the information from the text fields. /// </summary> protected override void ApplyFields() { // Apply each subservice. ApplySubService(DataStore.industry, Generic); ApplySubService(DataStore.industry_farm, Farming); ApplySubService(DataStore.industry_forest, Forestry); ApplySubService(DataStore.industry_oil, Oil); ApplySubService(DataStore.industry_ore, Ore); // Clear cached values. DataStore.prefabWorkerVisit.Clear(); // Save new settings. XMLUtilsWG.WriteToXML(); // Refresh settings. PopulateFields(); }
/// <summary> /// Sets the customised number of workers for a given prefab. /// If a record doesn't already exist, a new one will be created. /// </summary> /// <param name="prefab">The prefab (BuildingInfo) to set</param> /// <param name="workers">The updated worker count</param> public static void SetWorker(BuildingInfo prefab, int workers) { // Update or add entry to configuration file cache. if (DataStore.workerCache.ContainsKey(prefab.name)) { // Prefab already has a record; update. DataStore.workerCache[prefab.name] = workers; } else { // Prefab doesn't already have a record; create. DataStore.workerCache.Add(prefab.name, workers); } // Save the updated configuration file. XMLUtilsWG.WriteToXML(); // Get current building hash (for updating prefab dictionary). var prefabHash = prefab.gameObject.GetHashCode(); // Calculate employment breakdown. int[] array = CommercialBuildingAIMod.GetArray(prefab, (int)prefab.GetClassLevel()); PrefabEmployStruct output = new PrefabEmployStruct(); AI_Utils.CalculateprefabWorkerVisit(prefab.GetWidth(), prefab.GetLength(), ref prefab, 4, ref array, out output); // Update entry in 'live' settings. if (DataStore.prefabWorkerVisit.ContainsKey(prefabHash)) { // Prefab already has a record; update. DataStore.prefabWorkerVisit[prefabHash] = output; } else { // Prefab doesn't already have a record; create. DataStore.prefabWorkerVisit.Add(prefabHash, output); } }