/// <summary> /// Updates the given calculation pack with data from the panel. /// </summary> /// <param name="pack">Pack to update</param> protected override void UpdatePack(DataPack pack) { if (pack is VolumetricPopPack popPack) { // Basic pack attributes. pack.name = PackNameField.text; pack.displayName = PackNameField.text; // Iterate through each level, parsing input fields. for (int i = 0; i < maxLevels[serviceDropDown.selectedIndex]; ++i) { // Textfields. PanelUtils.ParseFloat(ref popPack.levels[i].emptyArea, emptyAreaFields[i].text); PanelUtils.ParseInt(ref popPack.levels[i].emptyPercent, emptyPercentFields[i].text); // Look at fixed population checkbox state to work out if we're doing fixed population or area per. if (fixedPopChecks[i].isChecked) { // Using fixed pop: negate the 'area per' number to denote fixed population. int pop = 0; PanelUtils.ParseInt(ref pop, fixedPopFields[i].text); popPack.levels[i].areaPer = 0 - pop; } else { // Area per unit. PanelUtils.ParseFloat(ref popPack.levels[i].areaPer, areaPerFields[i].text); } // Checkboxes. popPack.levels[i].multiFloorUnits = multiFloorChecks[i].isChecked; } } }
/// <summary> /// Updates the DataStore for a given SubService with information from text fields. /// </summary> /// <param name="dataArray">DataStore data array for the SubService</param> /// <param name="subService">SubService reference number</param> protected void ApplySubService(int[][] dataArray, int subService) { // Iterate though each level, populating each row as we go. for (int i = 0; i < powerFields[subService].Length; ++i) { PanelUtils.ParseInt(ref dataArray[i][DataStore.POWER], powerFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.WATER], waterFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.GARBAGE], garbageFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.SEWAGE], sewageFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.GROUND_POLLUTION], pollutionFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.NOISE_POLLUTION], noiseFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.MAIL], mailFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.INCOME], incomeFields[subService][i].text); } }
/// <summary> /// Updates the DataStore for a given SubService with information from text fields. /// </summary> /// <param name="dataArray">DataStore data array for the SubService</param> /// <param name="subService">SubService reference number</param> protected void ApplySubService(int[][] dataArray, int subService) { // Iterate though each level, populating each row as we go. for (int i = 0; i < areaFields[subService].Length; ++i) { PanelUtils.ParseInt(ref dataArray[i][DataStore.PEOPLE], areaFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.LEVEL_HEIGHT], floorFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.POWER], powerFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.WATER], waterFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.SEWAGE], sewageFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.GARBAGE], garbageFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.INCOME], incomeFields[subService][i].text); PanelUtils.ParseInt(ref dataArray[i][DataStore.PRODUCTION], productionFields[subService][i].text); // Extra floor field, if applicable. if (!(this is LegacyResidentialPanel)) { PanelUtils.ParseInt(ref dataArray[i][DataStore.DENSIFICATION], extraFloorFields[subService][i].text); } } }