public static bool CanOperation(ushort buildingID, ref Building buildingData, bool userReject = true) { if ((MainDataStore.resourceCategory[buildingID] == 4) && userReject) { return(false); } if (ResourceBuildingAI.IsSpecialBuilding(buildingID)) { return(false); } if (buildingData.Info.m_buildingAI is ParkBuildingAI) { return(false); } if (buildingData.Info.m_buildingAI is CampusBuildingAI) { return(false); } if (buildingData.Info.m_class.m_service == ItemClass.Service.Beautification) { return(false); } PlayerBuildingAI AI = buildingData.Info.m_buildingAI as PlayerBuildingAI; return(AI.RequireRoadAccess()); }
private void RefreshDisplayData() { if (refeshOnce || (MainDataStore.lastBuildingID != WorldInfoPanel.GetCurrentInstanceID().Building)) { if (base.isVisible) { MainDataStore.lastBuildingID = WorldInfoPanel.GetCurrentInstanceID().Building; Building buildingData = Singleton <BuildingManager> .instance.m_buildings.m_buffer[MainDataStore.lastBuildingID]; if (ResourceBuildingAI.IsSpecialBuilding(MainDataStore.lastBuildingID) == true) { this.food.text = string.Format(Localization.Get("FOOD_STORED") + " [{0}]", MainDataStore.foodBuffer[MainDataStore.lastBuildingID]); this.lumber.text = string.Format(Localization.Get("LUMBER_STORED") + " [{0}]", MainDataStore.lumberBuffer[MainDataStore.lastBuildingID]); this.coal.text = string.Format(Localization.Get("COAL_STORED") + " [{0}]", MainDataStore.coalBuffer[MainDataStore.lastBuildingID]); this.petrol.text = string.Format(Localization.Get("PETROL_STORED") + " [{0}]", MainDataStore.petrolBuffer[MainDataStore.lastBuildingID]); this.operationResource.text = string.Format(Localization.Get("OPERATION_RESOURCE") + " [{0}]", MainDataStore.operationResourceBuffer[MainDataStore.lastBuildingID]); this.constructionResource.text = string.Format(Localization.Get("CONSTRUCTION_RESOURCE") + " [{0}]", MainDataStore.constructionResourceBuffer[MainDataStore.lastBuildingID]); buildingType.text = Localization.Get("BUILDING_TYPE"); buildingTypeDD.items = new string[] { Localization.Get("NORMAL_BUILDING"), Localization.Get("GENERATE_BOTH_RESOURCES"), Localization.Get("GENERATE_CONSTRUCTION_RESOURCES"), Localization.Get("GENERATE_OPERATION_RESOURCES"), Localization.Get("NONEED_RESOURCE") }; if (buildingTypeDD.selectedIndex != MainDataStore.resourceCategory[MainDataStore.lastBuildingID]) { buildingTypeDD.selectedIndex = MainDataStore.resourceCategory[MainDataStore.lastBuildingID]; } } else { this.food.text = ""; this.lumber.text = ""; this.coal.text = ""; this.petrol.text = ""; this.constructionResource.text = ""; this.operationResource.text = string.Format(Localization.Get("OPERATION_RESOURCE_LEFT") + " [{0}]", MainDataStore.operationResourceBuffer[MainDataStore.lastBuildingID]); buildingType.text = Localization.Get("BUILDING_TYPE"); buildingTypeDD.items = new string[] { Localization.Get("NORMAL_BUILDING"), Localization.Get("GENERATE_BOTH_RESOURCES"), Localization.Get("GENERATE_CONSTRUCTION_RESOURCES"), Localization.Get("GENERATE_OPERATION_RESOURCES"), Localization.Get("NONEED_RESOURCE") }; if (buildingTypeDD.selectedIndex != MainDataStore.resourceCategory[MainDataStore.lastBuildingID]) { buildingTypeDD.selectedIndex = MainDataStore.resourceCategory[MainDataStore.lastBuildingID]; } } refeshOnce = false; this.BringToFront(); if (!CustomPlayerBuildingAI.CanOperation(MainDataStore.lastBuildingID, ref buildingData, false) && !ResourceBuildingAI.IsSpecialBuilding(MainDataStore.lastBuildingID)) { this.Hide(); } } else { this.Hide(); } } }
public static void StartTransfer(TransferManager.TransferReason material, TransferManager.TransferOffer offerOut, TransferManager.TransferOffer offerIn, int delta) { bool offerInActive = offerIn.Active; bool offerOutActive = offerOut.Active; if (offerInActive && offerIn.Vehicle != 0) { DebugLog.LogToFileOnly("Error: offerInActive && offerIn.Vehicle"); } else if (offerOutActive && offerOut.Vehicle != 0) { DebugLog.LogToFileOnly("Error: offerOutActive && offerOut.Vehicle"); } else if (offerInActive && offerIn.Citizen != 0u) { DebugLog.LogToFileOnly("Error: offerInActive && offerIn.Citizen"); } else if (offerOutActive && offerOut.Citizen != 0u) { DebugLog.LogToFileOnly("Error: offerOutActive && offerOut.Citizen"); } else if (offerOutActive && offerOut.Building != 0) { Array16 <Building> buildings = Singleton <BuildingManager> .instance.m_buildings; ushort building = offerOut.Building; offerIn.Amount = delta; if (ResourceBuildingAI.IsSpecialBuilding(building)) { StartSpecialBuildingTransfer(building, ref buildings.m_buffer[building], material, offerIn); } else { DebugLog.LogToFileOnly("Error: offerOutActive && offerOut.Building"); } } else if (offerInActive && offerIn.Building != 0) { DebugLog.LogToFileOnly("Error: offerInActive && offerIn.Building"); } }
public static void CargoTruckAISetSourceForRealConstruction(ushort vehicleID, ref Vehicle data, ushort sourceBuilding) { CargoTruckAI AI = data.Info.m_vehicleAI as CargoTruckAI; int num = Mathf.Min(0, (int)data.m_transferSize - AI.m_cargoCapacity); //new added begin if (ResourceBuildingAI.IsSpecialBuilding(sourceBuilding)) { if ((TransferManager.TransferReason)data.m_transferType == (TransferManager.TransferReason) 124) { MainDataStore.constructionResourceBuffer[sourceBuilding] -= 8000; } else if ((TransferManager.TransferReason)data.m_transferType == (TransferManager.TransferReason) 125) { MainDataStore.operationResourceBuffer[sourceBuilding] -= 8000; } else { DebugLog.LogToFileOnly("find unknow transfor for SpecialBuilding " + data.m_transferType.ToString()); } } }
public static void Postfix(ushort buildingID, ref Building buildingData, ref Building.Frame frameData) { // Update problems if (CustomPlayerBuildingAI.CanOperation(buildingID, ref buildingData) && buildingData.m_flags.IsFlagSet(Building.Flags.Completed) && (RealConstruction.operationConsumption != 2)) { OperationAI.ProcessPlayerBuildingOperation(buildingID, ref buildingData); if (MainDataStore.operationResourceBuffer[buildingID] > 100) { if (buildingData.Info.m_class.m_service == ItemClass.Service.PlayerIndustry) { if (buildingData.Info.m_class.m_subService == ItemClass.SubService.PlayerIndustryFarming) { if (RealConstruction.operationConsumption == 1) { MainDataStore.operationResourceBuffer[buildingID] -= 5; } else { MainDataStore.operationResourceBuffer[buildingID] -= 10; } } else if (buildingData.Info.m_class.m_subService == ItemClass.SubService.PlayerIndustryForestry) { if (RealConstruction.operationConsumption == 1) { MainDataStore.operationResourceBuffer[buildingID] -= 10; } else { MainDataStore.operationResourceBuffer[buildingID] -= 20; } } else if (buildingData.Info.m_class.m_subService == ItemClass.SubService.PlayerIndustryOre) { if (RealConstruction.operationConsumption == 1) { MainDataStore.operationResourceBuffer[buildingID] -= 15; } else { MainDataStore.operationResourceBuffer[buildingID] -= 30; } } else if (buildingData.Info.m_class.m_subService == ItemClass.SubService.PlayerIndustryOil) { if (RealConstruction.operationConsumption == 1) { MainDataStore.operationResourceBuffer[buildingID] -= 20; } else { MainDataStore.operationResourceBuffer[buildingID] -= 40; } } else { if (RealConstruction.operationConsumption == 1) { MainDataStore.operationResourceBuffer[buildingID] -= 25; } else { MainDataStore.operationResourceBuffer[buildingID] -= 50; } } } else { if (RealConstruction.operationConsumption == 1) { MainDataStore.operationResourceBuffer[buildingID] -= 50; } else { MainDataStore.operationResourceBuffer[buildingID] -= 100; } } if (CustomPlayerBuildingAI.CanRemoveNoResource(buildingID, ref buildingData)) { Notification.Problem problem = Notification.RemoveProblems(buildingData.m_problems, Notification.Problem.NoResources); buildingData.m_problems = problem; } } else { MainDataStore.operationResourceBuffer[buildingID] = 0; if (RealConstruction.debugMode) { if (buildingData.m_problems == Notification.Problem.None) { Notification.Problem problem = Notification.AddProblems(buildingData.m_problems, Notification.Problem.NoResources); buildingData.m_problems = problem; } } else { if (CustomPlayerBuildingAI.CanRemoveNoResource(buildingID, ref buildingData)) { Notification.Problem problem = Notification.RemoveProblems(buildingData.m_problems, Notification.Problem.NoResources); buildingData.m_problems = problem; } } } } else { if (CustomPlayerBuildingAI.CanRemoveNoResource(buildingID, ref buildingData)) { Notification.Problem problem = Notification.RemoveProblems(buildingData.m_problems, Notification.Problem.NoResources); buildingData.m_problems = problem; } } if (CustomPlayerBuildingAI.CanConstruction(buildingID, ref buildingData)) { if (!buildingData.m_flags.IsFlagSet(Building.Flags.Completed)) { ConstructionAI.ProcessBuildingConstruction(buildingID, ref buildingData, ref frameData); if (MainDataStore.constructionResourceBuffer[buildingID] >= 8000) { Notification.Problem problem = Notification.RemoveProblems(buildingData.m_problems, Notification.Problem.NoResources); buildingData.m_problems = problem; } else { if (RealConstruction.debugMode) { if (buildingData.m_problems == Notification.Problem.None) { Notification.Problem problem = Notification.AddProblems(buildingData.m_problems, Notification.Problem.NoResources); buildingData.m_problems = problem; } } } } } // if (ResourceBuildingAI.IsSpecialBuilding((ushort)buildingID)) { if (buildingData.m_flags.IsFlagSet(Building.Flags.Completed)) { ResourceBuildingAI.ProcessCityResourceDepartmentBuildingGoods(buildingID, ref buildingData); ResourceBuildingAI.ProcessCityResourceDepartmentBuildingOutgoing(buildingID, ref buildingData); ResourceBuildingAI.ProcessCityResourceDepartmentBuildingIncoming(buildingID, ref buildingData); } } }
public static void CargoTruckAIArriveAtTargetForRealConstruction(ushort vehicleID, ref Vehicle vehicleData) { BuildingManager instance = Singleton <BuildingManager> .instance; if (vehicleData.m_targetBuilding != 0) { Building buildingData = instance.m_buildings.m_buffer[vehicleData.m_targetBuilding]; if (!(buildingData.Info.m_buildingAI is OutsideConnectionAI)) { if (buildingData.m_flags.IsFlagSet(Building.Flags.Created) && (!buildingData.m_flags.IsFlagSet(Building.Flags.Completed)) && (!buildingData.m_flags.IsFlagSet(Building.Flags.Deleted))) { if (vehicleData.m_transferType == 124) { vehicleData.m_transferSize = 0; MainDataStore.constructionResourceBuffer[vehicleData.m_targetBuilding] = 8000; } } else { if (ResourceBuildingAI.IsSpecialBuilding(vehicleData.m_targetBuilding) == true) { switch ((TransferManager.TransferReason)vehicleData.m_transferType) { case TransferManager.TransferReason.Food: if (MainDataStore.foodBuffer[vehicleData.m_targetBuilding] < 57000) { MainDataStore.foodBuffer[vehicleData.m_targetBuilding] += vehicleData.m_transferSize; } if (Loader.isRealCityRunning) { float productionValue1 = vehicleData.m_transferSize * CustomCargoTruckAI.GetResourcePrice((TransferManager.TransferReason)vehicleData.m_transferType); Singleton <EconomyManager> .instance.FetchResource(EconomyManager.Resource.ResourcePrice, (int)productionValue1, ItemClass.Service.PlayerIndustry, ItemClass.SubService.PlayerIndustryFarming, ItemClass.Level.Level1); } vehicleData.m_transferSize = 0; break; case TransferManager.TransferReason.Lumber: if (MainDataStore.lumberBuffer[vehicleData.m_targetBuilding] < 57000) { MainDataStore.lumberBuffer[vehicleData.m_targetBuilding] += vehicleData.m_transferSize; } if (Loader.isRealCityRunning) { float productionValue1 = vehicleData.m_transferSize * CustomCargoTruckAI.GetResourcePrice((TransferManager.TransferReason)vehicleData.m_transferType); Singleton <EconomyManager> .instance.FetchResource(EconomyManager.Resource.ResourcePrice, (int)productionValue1, ItemClass.Service.PlayerIndustry, ItemClass.SubService.PlayerIndustryForestry, ItemClass.Level.Level1); } vehicleData.m_transferSize = 0; break; case TransferManager.TransferReason.Coal: if (MainDataStore.coalBuffer[vehicleData.m_targetBuilding] < 57000) { MainDataStore.coalBuffer[vehicleData.m_targetBuilding] += vehicleData.m_transferSize; } if (Loader.isRealCityRunning) { float productionValue1 = vehicleData.m_transferSize * CustomCargoTruckAI.GetResourcePrice((TransferManager.TransferReason)vehicleData.m_transferType); Singleton <EconomyManager> .instance.FetchResource(EconomyManager.Resource.ResourcePrice, (int)productionValue1, ItemClass.Service.PlayerIndustry, ItemClass.SubService.PlayerIndustryOre, ItemClass.Level.Level1); } vehicleData.m_transferSize = 0; break; case TransferManager.TransferReason.Petrol: if (MainDataStore.petrolBuffer[vehicleData.m_targetBuilding] < 57000) { MainDataStore.petrolBuffer[vehicleData.m_targetBuilding] += vehicleData.m_transferSize; } if (Loader.isRealCityRunning) { float productionValue1 = vehicleData.m_transferSize * CustomCargoTruckAI.GetResourcePrice((TransferManager.TransferReason)vehicleData.m_transferType); Singleton <EconomyManager> .instance.FetchResource(EconomyManager.Resource.ResourcePrice, (int)productionValue1, ItemClass.Service.PlayerIndustry, ItemClass.SubService.PlayerIndustryOil, ItemClass.Level.Level1); } vehicleData.m_transferSize = 0; break; default: //DebugLog.LogToFileOnly("Error: Unknow m_transferType in realconstruction = " + vehicleData.m_transferType.ToString()); break; } } else { if (vehicleData.m_transferType == 125) { vehicleData.m_transferSize = 0; MainDataStore.operationResourceBuffer[vehicleData.m_targetBuilding] += 8000; } } } } } }