public static void PassengerCarAIArriveAtTargetForRealGasStationPre(ref PassengerCarAI __instance, ushort vehicleID, ref Vehicle data) { var distance = Vector3.Distance(data.GetLastFramePosition(), Singleton <BuildingManager> .instance.m_buildings.m_buffer[MainDataStore.TargetGasBuilding[vehicleID]].m_position); if (distance < 80f) { if (MainDataStore.petrolBuffer[data.m_targetBuilding] > 400) { MainDataStore.petrolBuffer[data.m_targetBuilding] -= 400; } } __instance.SetTarget(vehicleID, ref data, 0); data.m_transferType = MainDataStore.preTranferReason[vehicleID]; if (MainDataStore.finalVehicleForFuelCount[MainDataStore.TargetGasBuilding[vehicleID]] > 0) { MainDataStore.finalVehicleForFuelCount[MainDataStore.TargetGasBuilding[vehicleID]]--; } MainDataStore.TargetGasBuilding[vehicleID] = 0; if (distance < 80f) { if (Loader.isRealCityRunning) { int money = (int)(400f * RealCityUtil.GetResourcePrice(TransferManager.TransferReason.Petrol) + 1000); ushort citizen = CarAISimulationStepPatch.GetDriverInstance(vehicleID, ref data); if (Singleton <CitizenManager> .instance.m_citizens.m_buffer[Singleton <CitizenManager> .instance.m_instances.m_buffer[citizen].m_citizen].m_flags.IsFlagSet(Citizen.Flags.DummyTraffic)) { Singleton <EconomyManager> .instance.AddResource(EconomyManager.Resource.PublicIncome, money, ItemClass.Service.Vehicles, ItemClass.SubService.PlayerIndustryOil, ItemClass.Level.Level1); } else { Singleton <EconomyManager> .instance.AddResource(EconomyManager.Resource.PublicIncome, money, ItemClass.Service.Vehicles, ItemClass.SubService.None, ItemClass.Level.Level1); } } } }
public static void CargoTruckAIArriveAtSourceForRealGasStationPre(ref CargoTruckAI __instance, ushort vehicleID, ref Vehicle data) { var distance = Vector3.Distance(data.GetLastFramePosition(), Singleton <BuildingManager> .instance.m_buildings.m_buffer[MainDataStore.TargetGasBuilding[vehicleID]].m_position); if (distance < 80f) { if (MainDataStore.petrolBuffer[MainDataStore.TargetGasBuilding[vehicleID]] > 400) { MainDataStore.petrolBuffer[MainDataStore.TargetGasBuilding[vehicleID]] -= 400; } } data.m_transferType = MainDataStore.preTranferReason[vehicleID]; PathManager instance = Singleton <PathManager> .instance; if (data.m_path != 0u) { instance.ReleasePath(data.m_path); data.m_path = 0; } __instance.SetTarget(vehicleID, ref data, data.m_targetBuilding); if (MainDataStore.finalVehicleForFuelCount[MainDataStore.TargetGasBuilding[vehicleID]] > 0) { MainDataStore.finalVehicleForFuelCount[MainDataStore.TargetGasBuilding[vehicleID]]--; } MainDataStore.TargetGasBuilding[vehicleID] = 0; if (distance < 80f) { if (Loader.isRealCityRunning) { int money = (int)(400f * RealCityUtil.GetResourcePrice(TransferManager.TransferReason.Petrol) + 1000); if (data.m_flags.IsFlagSet(Vehicle.Flags.DummyTraffic)) { Singleton <EconomyManager> .instance.AddResource(EconomyManager.Resource.PublicIncome, money, ItemClass.Service.Vehicles, ItemClass.SubService.PlayerIndustryOil, ItemClass.Level.Level2); } else { Singleton <EconomyManager> .instance.AddResource(EconomyManager.Resource.PublicIncome, money, ItemClass.Service.Vehicles, ItemClass.SubService.None, ItemClass.Level.Level2); } } } }
public static void CargoTruckAIArriveAtTargetForRealGasStationPost(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 (GasStationAI.IsGasBuilding(vehicleData.m_targetBuilding) == true) { switch ((TransferManager.TransferReason)vehicleData.m_transferType) { case TransferManager.TransferReason.Petrol: if (MainDataStore.petrolBuffer[vehicleData.m_targetBuilding] <= 57000) { MainDataStore.petrolBuffer[vehicleData.m_targetBuilding] += vehicleData.m_transferSize; } if (Loader.isRealCityRunning) { RealCityUtil.InitDelegate(); float productionValue = vehicleData.m_transferSize * RealCityUtil.GetResourcePrice((TransferManager.TransferReason)vehicleData.m_transferType); Singleton <EconomyManager> .instance.FetchResource(EconomyManager.Resource.ResourcePrice, (int)productionValue, ItemClass.Service.PlayerIndustry, ItemClass.SubService.PlayerIndustryOil, ItemClass.Level.Level1); } vehicleData.m_transferSize = 0; break; default: DebugLog.LogToFileOnly("Error: Find a import trade m_transferType = " + vehicleData.m_transferType.ToString()); break; } } } } }
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) { RealCityUtil.InitDelegate(); float productionValue1 = vehicleData.m_transferSize * RealCityUtil.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) { RealCityUtil.InitDelegate(); float productionValue1 = vehicleData.m_transferSize * RealCityUtil.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) { RealCityUtil.InitDelegate(); float productionValue1 = vehicleData.m_transferSize * RealCityUtil.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) { RealCityUtil.InitDelegate(); float productionValue1 = vehicleData.m_transferSize * RealCityUtil.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; } } } } } }