private void Deinit() { LoadPassengersPatch.Undo(); UnloadPassengersPatch.Undo(); DepotAIPatch.Undo(); NetManagerPatch.Undo(); VehicleManagerPatch.Undo(); PublicTransportLineVehicleModelSelectorRefreshPatch.Undo(); 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(); Redirector <TrolleybusAIDetour> .Revert(); Redirector <PassengerHelicopterAIDetour> .Revert(); Redirector <TransportLineDetour> .Revert(); TransportLineSimulationStepPatch.Undo(); TransportLineGetLineVehiclePatch.Undo(); CachedTransportLineData.Deinit(); BuildingExtension.Deinit(); CachedNodeData.Deinit(); CachedVehicleData.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); }
private void Deinit() { HarmonyInstance?.UnpatchAll(); 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(); Redirector <TrolleybusAIDetour> .Revert(); Redirector <PassengerHelicopterAIDetour> .Revert(); Redirector <TransportLineDetour> .Revert(); CachedTransportLineData.Deinit(); BuildingExtension.Deinit(); CachedNodeData.Deinit(); CachedVehicleData.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 static void Deinit() { VehiclePrefabs.instance = (VehiclePrefabs)null; }
public static void Init() { VehiclePrefabs.instance = new VehiclePrefabs(); VehiclePrefabs.instance.FindAllPrefabs(); }
private void FindAllPrefabs() { List <PrefabData> busList = new List <PrefabData>(); List <PrefabData> biofuelBusList = new List <PrefabData>(); List <PrefabData> metroList = new List <PrefabData>(); List <PrefabData> trainList = new List <PrefabData>(); List <PrefabData> shipList = new List <PrefabData>(); List <PrefabData> planeList = new List <PrefabData>(); List <PrefabData> taxiList = new List <PrefabData>(); List <PrefabData> tramList = new List <PrefabData>(); List <PrefabData> monorailList = new List <PrefabData>(); List <PrefabData> blimpList = new List <PrefabData>(); List <PrefabData> evacuationBusList = new List <PrefabData>(); List <PrefabData> cableCarList = new List <PrefabData>(); List <PrefabData> ferryList = new List <PrefabData>(); List <PrefabData> sightseeingBusList = new List <PrefabData>(); for (int index = 0; index < PrefabCollection <VehicleInfo> .PrefabCount(); ++index) { VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab((uint)index); if ((Object)prefab != (Object)null && !VehiclePrefabs.IsTrailer(prefab)) { var service = prefab.m_class.m_service; var subService = prefab.m_class.m_subService; var level = prefab.m_class.m_level; if (service == ItemClass.Service.Disaster && subService == ItemClass.SubService.None && level == ItemClass.Level.Level4) { evacuationBusList.Add(new PrefabData(prefab)); continue; } if (service == ItemClass.Service.PublicTransport) { if (level == ItemClass.Level.Level1) { switch (subService) { case ItemClass.SubService.PublicTransportBus: busList.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportMetro: metroList.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportTrain: trainList.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportShip: shipList.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportPlane: planeList.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportTaxi: taxiList.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportTram: tramList.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportMonorail: monorailList.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportCableCar: cableCarList.Add(new PrefabData(prefab)); continue; default: continue; } } if (level == ItemClass.Level.Level2) { switch (subService) { case ItemClass.SubService.PublicTransportBus: biofuelBusList.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportShip: ferryList.Add(new PrefabData(prefab)); continue; case ItemClass.SubService.PublicTransportPlane: blimpList.Add(new PrefabData(prefab)); continue; default: continue; } } if (level == ItemClass.Level.Level3) { switch (subService) { case ItemClass.SubService.PublicTransportTours: sightseeingBusList.Add(new PrefabData(prefab)); continue; default: continue; } } } } } this._busPrefabData = busList.ToArray(); this._biofuelBusPrefabData = biofuelBusList.ToArray(); this._metroPrefabData = metroList.ToArray(); this._trainPrefabData = trainList.ToArray(); this._shipPrefabData = shipList.ToArray(); this._planePrefabData = planeList.ToArray(); this._taxiPrefabData = taxiList.ToArray(); this._tramPrefabData = tramList.ToArray(); this._evacuationBusPrefabData = evacuationBusList.ToArray(); this._blimpPrefabData = blimpList.ToArray(); this._monorailPrefabData = monorailList.ToArray(); this._ferryPrefabData = ferryList.ToArray(); this._cablecarPrefabData = cableCarList.ToArray(); this._sightseeingBusPrefabData = sightseeingBusList.ToArray(); }
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 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)$"IPT2: 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>(); CachedNodeData.Init(); int maxVehicleCount; if (Utils.IsModActive(1764208250)) { UnityEngine.Debug.LogWarning("IPT2: More Vehicles is enabled, applying compatibility workaround"); maxVehicleCount = ushort.MaxValue + 1; } else { UnityEngine.Debug.Log("IPT2: More Vehicles is not enabled"); maxVehicleCount = VehicleManager.MAX_VEHICLE_COUNT; } CachedVehicleData.Init(maxVehicleCount); LoadPassengersPatch.Apply(); UnloadPassengersPatch.Apply(); DepotAIPatch.Apply(); NetManagerPatch.Apply(); VehicleManagerPatch.Apply(); PublicTransportLineVehicleModelSelectorRefreshPatch.Apply(); Redirector <BusAIDetour> .Deploy(); Redirector <TrolleybusAIDetour> .Deploy(); Redirector <PassengerTrainAIDetour> .Deploy(); Redirector <PassengerShipAIDetour> .Deploy(); Redirector <PassengerPlaneAIDetour> .Deploy(); Redirector <PassengerFerryAIDetour> .Deploy(); Redirector <PassengerBlimpAIDetour> .Deploy(); Redirector <PassengerHelicopterAIDetour> .Deploy(); Redirector <TramAIDetour> .Deploy(); Redirector <CommonBuildingAIReverseDetour> .Deploy(); Redirector <PublicTransportStopButtonDetour> .Deploy(); Redirector <PublicTransportVehicleButtonDetour> .Deploy(); Redirector <PublicTransportWorldInfoPanelDetour> .Deploy(); BuildingExtension.Init(); LineWatcher.instance.Init(); CachedTransportLineData.Init(); Redirector <TransportLineDetour> .Deploy(); TransportLineSimulationStepPatch.Apply(); TransportLineGetLineVehiclePatch.Apply(); 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)("IPT2: 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(); } }