void SaveDescription(string desc) { if (!m_allowEvents) { return; } int buildIndex = m_info.GetResilientBuildingIndex(m_currentSelectedBuildingID); if (buildIndex != -1) { ResilientBuildings.ResilientInfoV1 ri = m_info.m_resilients [buildIndex]; ri.description = desc; m_info.m_resilients [buildIndex] = ri; } }
private Level controlLevelUp(Level targetLevel, Level currentLevel, ushort buildingID) { int bi = s_info.GetResilientBuildingIndex(buildingID); if (bi != -1) //lock level { targetLevel = (Level)s_info.m_resilients[bi].chosenLevel; } return(targetLevel); }
public override int OnAddResource(EconomyResource resource, int amount, Service service, SubService subService, Level level) { if (!LoadingExtension.installed) { return(amount); } //check if OnAddResource call match what we are looking for if (!resource.Equals(EconomyResource.PrivateIncome)) //interested in private incomes only { return(amount); } if (service != Service.Office) //only office buildings tracked here { return(amount); } //CODebug.Log(LogChannel.Modding, Mod.modName + " - IncomeTracker search building with service " + service + " subservice " + subService + " level " + level + " amount "+amount); SimulationManager instance = Singleton <SimulationManager> .instance; BuildingManager instance2 = Singleton <BuildingManager> .instance; //sync with simulation frame if (checkedFrameIndex != instance.m_currentFrameIndex) { checkedFrameIndex = instance.m_currentFrameIndex; int num6 = (int)(instance.m_currentFrameIndex & 255u); buildingID = (ushort)(num6 * 192); maxBuildingID = (ushort)((num6 + 1) * 192 - 1); } //sync with BuildingManager SimulationStep loop bool skipping = true; bool error = false; do { if ((instance2.m_buildings.m_buffer[buildingID].m_flags & Building.Flags.Created) == Building.Flags.None) { skipping = true; } //abandoned buildings do no go through SimulationStepActive else if ((instance2.m_buildings.m_buffer[buildingID].m_flags & (Building.Flags.Abandoned | Building.Flags.BurnedDown)) != Building.Flags.None) { skipping = true; } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Residential) // { // skipping = false; // if(service != Service.Residential) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Industrial) // { // skipping = false; // if(service != Service.Industrial) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Commercial) // { // skipping = false; // if(service != Service.Commercial) // error = true; // } else if (instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Office) { skipping = false; } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Beautification) // { // skipping = false; // if(service != Service.Beautification) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Citizen) // { // skipping = false; // if(service != Service.Citizen) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Education) // { // skipping = false; // if(service != Service.Education) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Electricity) // { // skipping = false; // if(service != Service.Electricity) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.FireDepartment) // { // skipping = false; // if(service != Service.FireDepartment) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Garbage) // { // skipping = false; // if(service != Service.Garbage) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Government) // { // skipping = false; //// if(service != Service.Governement) //// error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.HealthCare) // { // skipping = false; // if(service != Service.HealthCare) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Monument) // { // skipping = false; // if(service != Service.Monument) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.PoliceDepartment) // { // skipping = false; // if(service != Service.PoliceDepartment) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.PublicTransport) // { // skipping = false; // if(service != Service.PublicTransport) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Road) // { // skipping = false; // if(service != Service.Road) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Water) // { // skipping = false; // if(service != Service.Water) // error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Unused1) // { // skipping = false; //// if(service != Service.) //// error = true; // } // else if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Unused2) // { // skipping = false; //// if(service != Service.Education) //// error = true; // } // else // { //// CODebug.Log(LogChannel.Modding, "income tracker private income for service "+instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service); //// skipping = true; // skipping = false; // if(instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service.ToString() != service.ToString()) // { // CODebug.Log(LogChannel.Modding, "income tracker mismatch "+instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service.ToString()+" "+service.ToString()); // } // } if (skipping) { buildingID++; if (buildingID > maxBuildingID) { error = true; skipping = false; } } }while(skipping); //check if active and history is activated if (!error) { if (instance2.m_buildings.m_buffer[buildingID].Info.m_class.m_service == ItemClass.Service.Office) { int buildIndex = s_info.GetResilientBuildingIndex((ushort)buildingID); String buildinfo2 = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID)); //CODebug.Log(LogChannel.Modding, Mod.modName + " - IncomeTracker found building with id " + buildingID + " buildIndex " + buildIndex + " " + buildinfo2); if (buildIndex != -1) { ResilientBuildings.ResilientInfoV1 ri = s_info.m_resilients[buildIndex]; ri.totalIncome += amount; s_info.m_resilients[buildIndex] = ri; } } buildingID++; //ensure search starts from next building at next function call } else { CODebug.Log(LogChannel.Modding, Mod.modName + " - IncomeTracker could not meet building with service " + service + " subservice " + subService + " level " + level); } return(amount); }