public override void OnSaveData() { base.OnSaveData(); if (managers.loading.currentMode == AppMode.Game) { var data = VehicleManagerMod.SaveData(); this.SaveData(data.Id, data); } }
private void Deinit() { Redirector <TramAIDetour> .Revert(); Redirector <PassengerTrainAIDetour> .Revert(); Redirector <PassengerShipAIDetour> .Revert(); Redirector <PassengerPlaneAIDetour> .Revert(); Redirector <PassengerFerryAIDetour> .Revert(); Redirector <PassengerBlimpAIDetour> .Revert(); Redirector <BusAIDetour> .Revert(); Redirector <CommonBuildingAIReverseDetour> .Revert(); Redirector <PublicTransportStopButtonDetour> .Revert(); Redirector <PublicTransportVehicleButtonDetour> .Revert(); Redirector <PublicTransportWorldInfoPanelDetour> .Revert(); TransportLineMod.Deinit(); BuildingExtension.Deinit(); NetManagerMod.Deinit(); VehicleManagerMod.Deinit(); VehiclePrefabs.Deinit(); SerializableDataExtension.instance.Loaded = false; LocaleModifier.Deinit(); if ((UnityEngine.Object) this._iptGameObject != (UnityEngine.Object)null) { UnityEngine.Object.Destroy((UnityEngine.Object) this._iptGameObject); } if (!((UnityEngine.Object) this._worldInfoPanel != (UnityEngine.Object)null)) { return; } UnityEngine.Object.Destroy((UnityEngine.Object) this._worldInfoPanel); }
public override void OnLoadData() { base.OnLoadData(); if (managers.loading.currentMode == AppMode.Game) { try { // Always try to load the latest version if possible. if (Vehiclesv1.TryLoadData(this, out Vehiclesv1 data)) { VehicleManagerMod.LoadData(data); } else { VehicleManagerMod.Clear(); } } catch (Exception ex) { Logger.LogException(ex); } } }
public override void OnLevelLoaded(LoadMode mode) { base.OnLevelLoaded(mode); if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame && mode != LoadMode.NewGameFromScenario) { return; } inGame = true; try { Utils.Log((object)$"Begin init version: {version}"); this.ReleaseUnusedCitizenUnits(); UIView objectOfType = UnityEngine.Object.FindObjectOfType <UIView>(); if ((UnityEngine.Object)objectOfType != (UnityEngine.Object)null) { this._iptGameObject = new GameObject("IptGameObject"); this._iptGameObject.transform.parent = objectOfType.transform; this._iptGameObject.AddComponent <SimHelper>(); this._iptGameObject.AddComponent <LineWatcher>(); this._worldInfoPanel = new GameObject("PublicTransportStopWorldInfoPanel"); this._worldInfoPanel.transform.parent = objectOfType.transform; this._worldInfoPanel.AddComponent <PublicTransportStopWorldInfoPanel>(); NetManagerMod.Init(); VehicleManagerMod.Init(); Redirector <BusAIDetour> .Deploy(); Redirector <PassengerTrainAIDetour> .Deploy(); Redirector <PassengerShipAIDetour> .Deploy(); Redirector <PassengerPlaneAIDetour> .Deploy(); Redirector <PassengerFerryAIDetour> .Deploy(); Redirector <PassengerBlimpAIDetour> .Deploy(); Redirector <TramAIDetour> .Deploy(); Redirector <CommonBuildingAIReverseDetour> .Deploy(); Redirector <PublicTransportStopButtonDetour> .Deploy(); Redirector <PublicTransportVehicleButtonDetour> .Deploy(); Redirector <PublicTransportWorldInfoPanelDetour> .Deploy(); BuildingExtension.Init(); LineWatcher.instance.Init(); TransportLineMod.Init(); VehiclePrefabs.Init(); SerializableDataExtension.instance.Loaded = true; LocaleModifier.Init(); this._iptGameObject.AddComponent <VehicleEditor>(); this._iptGameObject.AddComponent <PanelExtenderLine>(); this._iptGameObject.AddComponent <PanelExtenderVehicle>(); this._iptGameObject.AddComponent <PanelExtenderCityService>(); Utils.Log((object)"Loading done!"); } else { Utils.LogError((object)"UIView not found, aborting!"); } } catch (Exception ex) { Utils.LogError((object)("Error during initialization, IPT disables itself." + System.Environment.NewLine + "Please try again without any other mod." + System.Environment.NewLine + "Please upload your log file and post the link here if that didn't help:" + System.Environment.NewLine + "http://steamcommunity.com/workshop/filedetails/discussion/424106600/615086038663282271/" + System.Environment.NewLine + ex.Message + System.Environment.NewLine + (object)ex.InnerException + System.Environment.NewLine + ex.StackTrace)); this.Deinit(); } }
public static bool CopyPolicyTo(ushort building) { Constraints.ReleaseBuilding(building); Constraints.SetInternalSupplyReserve(building, Constraints.InternalSupplyBuffer(BuildingTemplate)); Constraints.SetAllInputLocalAreas(building, Constraints.InputAllLocalAreas(BuildingTemplate)); Constraints.SetAllOutputLocalAreas(building, Constraints.OutputAllLocalAreas(BuildingTemplate)); Constraints.SetAllInputOutsideConnections(building, Constraints.InputOutsideConnections(BuildingTemplate)); Constraints.SetAllOutputOutsideConnections(building, Constraints.OutputOutsideConnections(BuildingTemplate)); var inputDistrictsServed = Constraints.InputDistrictParkServiced(BuildingTemplate); if (inputDistrictsServed != null) { foreach (var districtPark in inputDistrictsServed) { Constraints.AddInputDistrictParkServiced(building, districtPark); } } var outputDistrictsServed = Constraints.OutputDistrictParkServiced(BuildingTemplate); if (outputDistrictsServed != null) { foreach (var districtPark in outputDistrictsServed) { Constraints.AddOutputDistrictParkServiced(building, districtPark); } } bool copySucceeded = true; var supplySources = Constraints.SupplySources(BuildingTemplate); for (int index = 0; index < supplySources?.Count; index++) { if (TransferManagerInfo.IsValidSupplyChainLink((ushort)supplySources[index], building)) { Constraints.AddSupplyChainConnection((ushort)supplySources[index], building); } else { copySucceeded = false; } } var supplyDestinations = Constraints.SupplyDestinations(BuildingTemplate); for (int index = 0; index < supplyDestinations?.Count; index++) { if (TransferManagerInfo.IsValidSupplyChainLink(building, (ushort)supplyDestinations[index])) { Constraints.AddSupplyChainConnection(building, (ushort)supplyDestinations[index]); } else { copySucceeded = false; } } VehicleManagerMod.ReleaseBuilding(building); VehicleManagerMod.SetBuildingUseDefaultVehicles(building, VehicleManagerMod.BuildingUseDefaultVehicles[BuildingTemplate]); if (VehicleManagerMod.BuildingToVehicles[BuildingTemplate] != null && VehicleManagerMod.BuildingToVehicles[BuildingTemplate].Count > 0) { foreach (var prefabIndex in VehicleManagerMod.BuildingToVehicles[BuildingTemplate]) { VehicleManagerMod.AddCustomVehicle(building, prefabIndex); } } return(copySucceeded); }