public void ReleaseVehicle(ushort vehicleID)
 {
     if (!VehicleManagerMod.m_cachedVehicleData[(int)vehicleID].IsEmpty)
     {
         VehicleManagerMod.m_cachedVehicleData[(int)vehicleID] = new VehicleData();
     }
     VehicleManagerMod.ReleaseVehicleImplementation(vehicleID, ref Singleton <VehicleManager> .instance.m_vehicles.m_buffer[(int)vehicleID]);
 }
 public void OnLevelLoaded(LoadMode mode)
 {
     this._loadMode = mode;
     if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame)
     {
         return;
     }
     try
     {
         Utils.Log((object)"Begin init version: 3.8.10");
         ImprovedPublicTransportMod.Settings.LogSettings();
         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 <VehicleEditor>();
             this._iptGameObject.AddComponent <PanelExtenderLine>();
             this._iptGameObject.AddComponent <PanelExtenderVehicle>();
             this._iptGameObject.AddComponent <PanelExtenderCityService>();
             this._iptGameObject.AddComponent <SimHelper>();
             this._iptGameObject.AddComponent <LineWatcher>();
             this._worldInfoPanel = new GameObject("PublicTransportStopWorldInfoPanel");
             this._worldInfoPanel.transform.parent = objectOfType.transform;
             this._worldInfoPanel.AddComponent <PublicTransportStopWorldInfoPanel>().Show();
             NetManagerMod.Init();
             VehicleManagerMod.Init();
             BusAIMod.Init();
             PassengerTrainAIMod.Init();
             PassengerShipAIMod.Init();
             PassengerPlaneAIMod.Init();
             TramAIMod.Init();
             BuildingWatcher.instance.Init();
             LineWatcher.instance.Init();
             TransportLineMod.Init();
             VehiclePrefabs.Init();
             SerializableDataExtension.instance.Loaded = true;
             LocaleModifier.Init();
             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 void Init()
 {
     if (VehicleManagerMod._isDeployed)
     {
         return;
     }
     if (!VehicleManagerMod.TryLoadData(out VehicleManagerMod.m_cachedVehicleData))
     {
         Utils.Log((object)"Loading default vehicle data.");
     }
     VehicleManagerMod.ReleaseVehicleImplementation = (VehicleManagerMod.ReleaseVehicleImplementationCallback)Utils.CreateDelegate <VehicleManager, VehicleManagerMod.ReleaseVehicleImplementationCallback>("ReleaseVehicleImplementation", (object)Singleton <VehicleManager> .instance);
     VehicleManagerMod._redirection = new Redirection <VehicleManager, VehicleManagerMod>("ReleaseVehicle");
     SerializableDataExtension.instance.EventSaveData += new SerializableDataExtension.SaveDataEventHandler(VehicleManagerMod.OnSaveData);
     VehicleManagerMod._isDeployed = true;
 }
        public static ushort StartTransfer(ushort buildingID, ref Building data, TransferManager.TransferReason reason, TransferManager.TransferOffer offer, string prefabName)
        {
            SimulationManager instance1  = Singleton <SimulationManager> .instance;
            VehicleManager    instance2  = Singleton <VehicleManager> .instance;
            ushort            vehicle    = 0;
            DepotAI           buildingAi = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)buildingID].Info.m_buildingAI as DepotAI;

            if (reason == buildingAi.m_transportInfo.m_vehicleReason)
            {
                VehicleInfo vehicleInfo = VehicleManagerMod.GetVehicleInfo(ref instance1.m_randomizer, buildingAi.m_info.m_class, offer.TransportLine, prefabName);
                if ((Object)vehicleInfo != (Object)null)
                {
                    Vector3 position;
                    Vector3 target;
                    buildingAi.CalculateSpawnPosition(buildingID, ref data, ref instance1.m_randomizer, vehicleInfo, out position, out target);
                    if (instance2.CreateVehicle(out vehicle, ref instance1.m_randomizer, vehicleInfo, position, reason, false, true))
                    {
                        vehicleInfo.m_vehicleAI.SetSource(vehicle, ref instance2.m_vehicles.m_buffer[(int)vehicle], buildingID);
                        vehicleInfo.m_vehicleAI.StartTransfer(vehicle, ref instance2.m_vehicles.m_buffer[(int)vehicle], reason, offer);
                    }
                }
            }
            return(vehicle);
        }
 private void Deinit()
 {
     TramAIMod.Deinit();
     PassengerTrainAIMod.Deinit();
     PassengerShipAIMod.Deinit();
     PassengerPlaneAIMod.Deinit();
     BusAIMod.Deinit();
     TransportLineMod.Deinit();
     BuildingWatcher.instance.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);
 }