public static void Prefix(ushort buildingID, ref Building data, TransferManager.TransferReason material, ref int amountDelta) { RealCityIndustrialBuildingAI.InitDelegate(); if (material == RealCityIndustrialBuildingAI.GetOutgoingTransferReason((IndustrialBuildingAI)(data.Info.m_buildingAI))) { RevertTradeIncome(buildingID, ref data, material, ref amountDelta); } }
public static void Postfix(ushort buildingID, ref Building data, TransferManager.TransferReason material, ref int amountDelta) { RealCityIndustrialBuildingAI.InitDelegate(); if (material == RealCityIndustrialBuildingAI.GetIncomingTransferReason((IndustrialBuildingAI)(data.Info.m_buildingAI), buildingID) || material == RealCityIndustrialBuildingAI.GetSecondaryIncomingTransferReason((IndustrialBuildingAI)(data.Info.m_buildingAI), buildingID)) { ProcessIncoming(buildingID, material, ref amountDelta); } else if (material == RealCityIndustrialBuildingAI.GetOutgoingTransferReason((IndustrialBuildingAI)(data.Info.m_buildingAI))) { CaculateTradeIncome(buildingID, ref data, material, ref amountDelta); } }
private void RefreshDisplayData() { if (refeshOnce || (BuildingData.lastBuildingID != WorldInfoPanel.GetCurrentInstanceID().Building)) { if (isVisible) { BuildingData.lastBuildingID = WorldInfoPanel.GetCurrentInstanceID().Building; Building buildingData = Singleton <BuildingManager> .instance.m_buildings.m_buffer[BuildingData.lastBuildingID]; if (buildingData.Info.m_class.m_service == ItemClass.Service.Residential) { Hide(); } else { float averageEmployeeFee = CaculateEmployeeOutcome(buildingData, out int totalWorkerCount); int landRentFee = CaculateLandFee(buildingData, BuildingData.lastBuildingID); string incomeType = RealCityPrivateBuildingAI.GetProductionType(false, BuildingData.lastBuildingID, buildingData); string outgoingType = RealCityPrivateBuildingAI.GetProductionType(true, BuildingData.lastBuildingID, buildingData); float incomePrice = RealCityPrivateBuildingAI.GetPrice(false, BuildingData.lastBuildingID, buildingData); float outgoingPrice = RealCityPrivateBuildingAI.GetPrice(true, BuildingData.lastBuildingID, buildingData); buildingMoney.text = string.Format(Localization.Get("BUILDING_MONEY") + " [{0}]", BuildingData.buildingMoney[BuildingData.lastBuildingID]); buildingNetAsset.text = string.Format(Localization.Get("BUILDING_NETASSET") + " [{0}]", (BuildingData.buildingMoney[BuildingData.lastBuildingID] + buildingData.m_customBuffer1 * RealCityIndustryBuildingAI.GetResourcePrice(RealCityPrivateBuildingAI.GetIncomingProductionType(BuildingData.lastBuildingID, buildingData)))); buildingIncomeBuffer.text = string.Format(Localization.Get("MATERIAL_BUFFER") + " [{0}]" + " " + incomeType, buildingData.m_customBuffer1); buildingOutgoingBuffer.text = string.Format(Localization.Get("PRODUCTION_BUFFER") + " [{0}]" + " " + outgoingType, buildingData.m_customBuffer2); employFee.text = Localization.Get("AVERAGE_EMPLOYFEE") + " " + averageEmployeeFee.ToString() + " " + Localization.Get("PROFIT_SHARING"); landRent.text = string.Format(Localization.Get("BUILDING_LANDRENT") + " [{0:N2}]", landRentFee); buyPrice.text = string.Format(Localization.Get("BUY_PRICE") + " " + incomeType + "[{0:N2}]", incomePrice); sellPrice.text = string.Format(Localization.Get("SELL_PRICE") + " " + outgoingType + " [{0:N2}]", outgoingPrice); float consumptionDivider = 0f; if (buildingData.Info.m_class.m_subService == ItemClass.SubService.IndustrialGeneric) { consumptionDivider = RealCityPrivateBuildingAI.GetComsumptionDivider(buildingData, BuildingData.lastBuildingID) * 4f; comsuptionDivide.text = string.Format(Localization.Get("MATERIAL_DIV_PRODUCTION") + " [1:{0:N2}]", consumptionDivider); } else { if ((buildingData.Info.m_buildingAI is IndustrialExtractorAI) || buildingData.Info.m_class.m_service == ItemClass.Service.Office) { comsuptionDivide.text = string.Format(Localization.Get("MATERIAL_DIV_PRODUCTION") + " N/A"); } else { consumptionDivider = RealCityPrivateBuildingAI.GetComsumptionDivider(buildingData, BuildingData.lastBuildingID); comsuptionDivide.text = string.Format(Localization.Get("MATERIAL_DIV_PRODUCTION") + " [1:{0:N2}]", consumptionDivider); } } int m_sellTax = RealCityPrivateBuildingAI.GetTaxRate(buildingData); sellTax.text = string.Format(Localization.Get("SELL_TAX") + " [{0}%]", m_sellTax); if (consumptionDivider == 0f) { profit.text = string.Format(Localization.Get("PROFIT") + " N/A"); } else { float profitRatio = (outgoingPrice * (1f - m_sellTax / 100f) - (incomePrice / consumptionDivider)) / outgoingPrice; if (buildingData.Info.m_class.m_service == ItemClass.Service.Commercial) { profit.text = string.Format(Localization.Get("PROFIT") + " [{0}%]" + Localization.Get("EXCLUDE_VISIT_INCOME"), (int)(profitRatio * 100f)); } else { profit.text = string.Format(Localization.Get("PROFIT") + " [{0}%]", (int)(profitRatio * 100f)); } } int usedCar = 0; int num = 0; int num1 = 0; int num2 = 0; int car = 0; if (buildingData.Info.m_class.m_service == ItemClass.Service.Industrial) { TransferManager.TransferReason tempReason = default(TransferManager.TransferReason); if (buildingData.Info.m_buildingAI is IndustrialExtractorAI) { RealCityIndustrialExtractorAI.InitDelegate(); var industrialExtractorAI = (IndustrialExtractorAI)buildingData.Info.m_buildingAI; int productionCapacity = industrialExtractorAI.CalculateProductionCapacity((ItemClass.Level)buildingData.m_level, new Randomizer(BuildingData.lastBuildingID), buildingData.m_width, buildingData.m_length); car = Mathf.Max(1, productionCapacity / 6); tempReason = RealCityIndustrialExtractorAI.GetOutgoingTransferReason((IndustrialExtractorAI)buildingData.Info.m_buildingAI); RealCityCommonBuildingAI.InitDelegate(); RealCityCommonBuildingAI.CalculateOwnVehicles((IndustrialExtractorAI)buildingData.Info.m_buildingAI, BuildingData.lastBuildingID, ref buildingData, tempReason, ref usedCar, ref num, ref num1, ref num2); } else { RealCityIndustrialBuildingAI.InitDelegate(); var industrialBuildingAI = (IndustrialBuildingAI)buildingData.Info.m_buildingAI; int productionCapacity = industrialBuildingAI.CalculateProductionCapacity((ItemClass.Level)buildingData.m_level, new Randomizer(BuildingData.lastBuildingID), buildingData.m_width, buildingData.m_length); car = Mathf.Max(1, productionCapacity / 6); tempReason = RealCityIndustrialBuildingAI.GetOutgoingTransferReason((IndustrialBuildingAI)buildingData.Info.m_buildingAI); RealCityCommonBuildingAI.InitDelegate(); RealCityCommonBuildingAI.CalculateOwnVehicles((IndustrialBuildingAI)buildingData.Info.m_buildingAI, BuildingData.lastBuildingID, ref buildingData, tempReason, ref usedCar, ref num, ref num1, ref num2); } usedcar.text = string.Format(Localization.Get("CAR_USED") + " [{0}/{1}]", usedCar, car); } else if (buildingData.Info.m_class.m_service == ItemClass.Service.Commercial) { Citizen.BehaviourData behaviour = default; int aliveVisitCount = 0; int totalVisitCount = 0; RealCityCommercialBuildingAI.InitDelegate(); RealCityCommercialBuildingAI.GetVisitBehaviour((CommercialBuildingAI)(buildingData.Info.m_buildingAI), BuildingData.lastBuildingID, ref buildingData, ref behaviour, ref aliveVisitCount, ref totalVisitCount); var amount = buildingData.m_customBuffer2 / MainDataStore.maxGoodPurchase - totalVisitCount + aliveVisitCount; var commercialBuildingAI = buildingData.Info.m_buildingAI as CommercialBuildingAI; var maxCount = commercialBuildingAI.CalculateVisitplaceCount((ItemClass.Level)buildingData.m_level, new Randomizer(BuildingData.lastBuildingID), buildingData.m_width, buildingData.m_length); usedcar.text = string.Format("FORDEBUG" + " [{0}/{1}/{2}/{3}]", aliveVisitCount, totalVisitCount, maxCount, amount); } else { usedcar.text = Localization.Get("CAR_USED") + " 0/0"; } BringToFront(); refeshOnce = false; } } } }