public static void Postfix(ushort buildingID, ref Building data) { RealCityIndustrialBuildingAI.InitDelegate(); var material = RealCityIndustrialBuildingAI.GetIncomingTransferReason((IndustrialBuildingAI)(data.Info.m_buildingAI), buildingID); float initialMaterialFee = data.m_customBuffer1 * RealCityIndustryBuildingAI.GetResourcePrice(material) + 10000; BuildingData.buildingMoney[buildingID] = -initialMaterialFee; }
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); } }
public static bool Prefix(TransferManager.TransferReason material, ref TransferManager.TransferOffer offer) { switch (material) { case TransferManager.TransferReason.Shopping: case TransferManager.TransferReason.ShoppingB: case TransferManager.TransferReason.ShoppingC: case TransferManager.TransferReason.ShoppingD: case TransferManager.TransferReason.ShoppingE: case TransferManager.TransferReason.ShoppingF: case TransferManager.TransferReason.ShoppingG: case TransferManager.TransferReason.ShoppingH: case TransferManager.TransferReason.Entertainment: case TransferManager.TransferReason.EntertainmentB: case TransferManager.TransferReason.EntertainmentC: case TransferManager.TransferReason.EntertainmentD: case TransferManager.TransferReason.TouristA: case TransferManager.TransferReason.TouristB: case TransferManager.TransferReason.TouristC: case TransferManager.TransferReason.TouristD: if (RealCity.realCityV10) { if (MainDataStore.outsideTouristMoney < 0) { if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[offer.Building].Info.m_buildingAI is OutsideConnectionAI) { return(false); } } } break; case TransferManager.TransferReason.Oil: case TransferManager.TransferReason.Ore: case TransferManager.TransferReason.Coal: case TransferManager.TransferReason.Petrol: case TransferManager.TransferReason.Food: case TransferManager.TransferReason.Grain: case TransferManager.TransferReason.Lumber: case TransferManager.TransferReason.Logs: case TransferManager.TransferReason.Goods: case TransferManager.TransferReason.LuxuryProducts: case TransferManager.TransferReason.AnimalProducts: case TransferManager.TransferReason.Flours: case TransferManager.TransferReason.Petroleum: case TransferManager.TransferReason.Plastics: case TransferManager.TransferReason.Metals: case TransferManager.TransferReason.Glass: case TransferManager.TransferReason.PlanedTimber: case TransferManager.TransferReason.Paper: break; default: return(true); } if (offer.Citizen != 0) { var instance = Singleton <CitizenManager> .instance; ushort homeBuilding = instance.m_citizens.m_buffer[offer.Citizen].m_homeBuilding; uint citizenUnit = CitizenData.GetCitizenUnit(homeBuilding); uint containingUnit = instance.m_citizens.m_buffer[offer.Citizen].GetContainingUnit((uint)offer.Citizen, citizenUnit, CitizenUnit.Flags.Home); if (!instance.m_citizens.m_buffer[offer.Citizen].m_flags.IsFlagSet(Citizen.Flags.Tourist)) { if (CitizenUnitData.familyMoney[containingUnit] < MainDataStore.maxGoodPurchase * RealCityIndustryBuildingAI.GetResourcePrice(TransferManager.TransferReason.Shopping)) { //Reject poor citizen to building return(false); } } } else if (offer.Building != 0) { var instance = Singleton <BuildingManager> .instance; var buildingID = offer.Building; var buildingData = instance.m_buildings.m_buffer[buildingID]; if (buildingData.Info.m_class.m_service == ItemClass.Service.Industrial) { RealCityIndustrialBuildingAI.InitDelegate(); RealCityCommonBuildingAI.InitDelegate(); var industrialBuildingAI = buildingData.Info.m_buildingAI as IndustrialBuildingAI; TransferManager.TransferReason incomingTransferReason = RealCityIndustrialBuildingAI.GetIncomingTransferReason((IndustrialBuildingAI)(buildingData.Info.m_buildingAI), buildingID); TransferManager.TransferReason secondaryIncomingTransferReason = RealCityIndustrialBuildingAI.GetSecondaryIncomingTransferReason((IndustrialBuildingAI)(buildingData.Info.m_buildingAI), buildingID); int maxIncomingLoadSize = RealCityIndustrialBuildingAI.MaxIncomingLoadSize((IndustrialBuildingAI)(buildingData.Info.m_buildingAI)); int num = 0; int num1 = 0; int incomingCargoCapacity = 0; int value = 0; if (incomingTransferReason != TransferManager.TransferReason.None) { if (secondaryIncomingTransferReason != TransferManager.TransferReason.None) { RealCityCommonBuildingAI.CalculateGuestVehicles1((IndustrialBuildingAI)(buildingData.Info.m_buildingAI), buildingID, ref buildingData, incomingTransferReason, secondaryIncomingTransferReason, ref num, ref num1, ref incomingCargoCapacity, ref value); } else { RealCityCommonBuildingAI.CalculateGuestVehicles((IndustrialBuildingAI)(buildingData.Info.m_buildingAI), buildingID, ref buildingData, incomingTransferReason, ref num, ref num1, ref incomingCargoCapacity, ref value); } } int productionCapacity = industrialBuildingAI.CalculateProductionCapacity((ItemClass.Level)buildingData.m_level, new Randomizer((int)buildingID), buildingData.m_width, buildingData.m_length); int consumptionDivider = RealCityIndustrialBuildingAI.GetConsumptionDivider((IndustrialBuildingAI)(buildingData.Info.m_buildingAI)); int fullCapacity = Mathf.Max(productionCapacity * 500 / consumptionDivider, maxIncomingLoadSize * 4); int incomingAmontNeeded = fullCapacity - (int)buildingData.m_customBuffer1 - incomingCargoCapacity; incomingAmontNeeded -= 8000; if (incomingAmontNeeded < 0) { return(false); } else { if (material == incomingTransferReason) { //first remove. //game bug, will send 2 incomingTransferReason per period TransferManager.TransferOffer offer1 = default; offer1.Building = buildingID; Singleton <TransferManager> .instance.RemoveIncomingOffer(incomingTransferReason, offer1); } } } else if (buildingData.Info.m_class.m_service == ItemClass.Service.Commercial) { RealCityCommercialBuildingAI.InitDelegate(); RealCityCommonBuildingAI.InitDelegate(); var commercialBuildingAI = buildingData.Info.m_buildingAI as CommercialBuildingAI; int maxIncomingLoadSize = RealCityCommercialBuildingAI.MaxIncomingLoadSize((CommercialBuildingAI)(buildingData.Info.m_buildingAI)); int visitplaceCount = commercialBuildingAI.CalculateVisitplaceCount((ItemClass.Level)buildingData.m_level, new Randomizer((int)buildingID), buildingData.m_width, buildingData.m_length); int fullCapacity = Mathf.Max(visitplaceCount * 500, maxIncomingLoadSize * 4); int num = 0; int num1 = 0; int incomingCargoCapacity = 0; int value = 0; TransferManager.TransferReason incomingTransferReason = RealCityCommercialBuildingAI.GetIncomingTransferReason((CommercialBuildingAI)(buildingData.Info.m_buildingAI)); if (incomingTransferReason != TransferManager.TransferReason.None) { if (incomingTransferReason == TransferManager.TransferReason.Goods || incomingTransferReason == TransferManager.TransferReason.Food) { RealCityCommonBuildingAI.CalculateGuestVehicles1((CommercialBuildingAI)(buildingData.Info.m_buildingAI), buildingID, ref buildingData, incomingTransferReason, TransferManager.TransferReason.LuxuryProducts, ref num, ref num1, ref incomingCargoCapacity, ref value); } else { RealCityCommonBuildingAI.CalculateGuestVehicles((CommercialBuildingAI)(buildingData.Info.m_buildingAI), buildingID, ref buildingData, incomingTransferReason, ref num, ref num1, ref incomingCargoCapacity, ref value); } buildingData.m_tempImport = (byte)Mathf.Clamp(value, (int)buildingData.m_tempImport, 255); } int incomingAmontNeeded = fullCapacity - (int)buildingData.m_customBuffer1 - incomingCargoCapacity; incomingAmontNeeded -= 6000; if (incomingAmontNeeded < 0) { return(false); } } } return(true); }
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; } } } }