private void OnCapacitySubmitted(UIComponent component, string text) { if (this._selectedIndex <= -1 || this._selectedSubService == ItemClass.SubService.PublicTransportTaxi) { return; } PrefabData prefab = GetPrefabs()[this._selectedIndex]; int carCount = prefab.CarCount; int int32 = Utils.ToInt32(text); int num1 = 0; if (int32 > 0) { num1 = Utils.RoundToNearest((float)(int32 / carCount), 5) * carCount; (component as UITextField).text = num1.ToString(); } UITextField uiTextField = this._rightSidePanel.Find <UITextField>("MaintenanceCost"); if (!uiTextField.parent.enabled) { return; } float num2 = (float)num1 / (float)carCount / (float)GameDefault.GetCapacity(prefab.Info.GetService(), prefab.Info.GetSubService(), prefab.Info.GetClassLevel()); uiTextField.text = Mathf.RoundToInt((float)(PrefabData.GetMaintenanceCost(prefab.Info.GetService(), prefab.Info.GetSubService(), prefab.Info.GetClassLevel(), prefab.Info.m_vehicleAI) * 16) * num2).ToString(); }
private void LoadPrefabData() { try { string str = "IptVehicleData"; if (!Directory.Exists(str)) { Directory.CreateDirectory(str); } string path2 = Utils.RemoveInvalidFileNameChars(this.ObjectName + ".xml"); string path = System.IO.Path.Combine(str, path2); if (!File.Exists(path)) { Utils.Log((object)("No stored data found for " + this.ObjectName)); } else { Utils.Log((object)("Found stored data for " + this.ObjectName)); using (StreamReader streamReader = new StreamReader(path)) { PrefabData.DefaultPrefabData defaultPrefabData = (PrefabData.DefaultPrefabData) new XmlSerializer(typeof(PrefabData.DefaultPrefabData)).Deserialize((TextReader)streamReader); this.Capacity = defaultPrefabData.Capacity; this.MaintenanceCost = defaultPrefabData.MaintenanceCost; this.MaxSpeed = defaultPrefabData.MaxSpeed; this.EngineOnBothEnds = defaultPrefabData.EngineOnBothEnds; this._changeFlag = false; } } } catch (Exception ex) { Utils.LogError((object)(ex.Message + System.Environment.NewLine + ex.StackTrace)); } }
private void SavePrefabData() { if (!this._saveToXml) { return; } try { string str = "IptVehicleData"; if (!Directory.Exists(str)) { Directory.CreateDirectory(str); } string path2 = Utils.RemoveInvalidFileNameChars(this.ObjectName + ".xml"); string path = System.IO.Path.Combine(str, path2); PrefabData.DefaultPrefabData defaultPrefabData = new PrefabData.DefaultPrefabData(); defaultPrefabData.Capacity = this.Capacity; defaultPrefabData.MaintenanceCost = this.MaintenanceCost; defaultPrefabData.MaxSpeed = this.MaxSpeed; defaultPrefabData.EngineOnBothEnds = this.EngineOnBothEnds; using (StreamWriter streamWriter = new StreamWriter(path)) new XmlSerializer(typeof(PrefabData.DefaultPrefabData)).Serialize((TextWriter)streamWriter, (object)defaultPrefabData); } catch (Exception ex) { Utils.LogError((object)(ex.Message + System.Environment.NewLine + ex.StackTrace)); } }
private static void OnSaveData() { FastList <byte> data = new FastList <byte>(); try { SerializableDataExtension.WriteString(CachedVehicleData._dataVersion, data); for (int index = 0; index < CachedVehicleData.MaxVehicleCount; ++index) { if (!CachedVehicleData.m_cachedVehicleData[index].IsEmpty) { SerializableDataExtension.WriteInt32(index, data); SerializableDataExtension.WriteInt32(CachedVehicleData.m_cachedVehicleData[index].LastStopNewPassengers, data); SerializableDataExtension.WriteInt32(CachedVehicleData.m_cachedVehicleData[index].LastStopGonePassengers, data); SerializableDataExtension.WriteInt32(CachedVehicleData.m_cachedVehicleData[index].PassengersThisWeek, data); SerializableDataExtension.WriteInt32(CachedVehicleData.m_cachedVehicleData[index].PassengersLastWeek, data); SerializableDataExtension.WriteInt32(CachedVehicleData.m_cachedVehicleData[index].IncomeThisWeek, data); SerializableDataExtension.WriteInt32(CachedVehicleData.m_cachedVehicleData[index].IncomeLastWeek, data); SerializableDataExtension.WriteFloatArray(CachedVehicleData.m_cachedVehicleData[index].PassengerData, data); SerializableDataExtension.WriteFloatArray(CachedVehicleData.m_cachedVehicleData[index].IncomeData, data); SerializableDataExtension.WriteUInt16(CachedVehicleData.m_cachedVehicleData[index].CurrentStop, data); } } SerializableDataExtension.instance.SerializableData.SaveData(CachedVehicleData._dataID, data.ToArray()); } catch (Exception ex) { Utils.LogError((object)("Error while saving vehicle data! " + ex.Message + " " + (object)ex.InnerException)); } }
public static void Init() { if (Utils.IsModActive(1764208250)) { UnityEngine.Debug.LogWarning("More Vehicles is enabled, applying compatibility workaround"); MaxVehicleCount = ushort.MaxValue + 1; } else { UnityEngine.Debug.Log("More Vehicles is not enabled"); MaxVehicleCount = VehicleManager.MAX_VEHICLE_COUNT; } if (CachedVehicleData._isDeployed) { return; } if (!CachedVehicleData.TryLoadData(out CachedVehicleData.m_cachedVehicleData)) { Utils.Log((object)"Loading default vehicle data."); } SerializableDataExtension.instance.EventSaveData += new SerializableDataExtension.SaveDataEventHandler(CachedVehicleData.OnSaveData); CachedVehicleData._isDeployed = true; }
public override void OnLevelUnloading() { base.OnLevelUnloading(); if (!inGame) { return; } inGame = false; this.Deinit(); Utils.Log((object)("Unloading done!" + System.Environment.NewLine)); }
public PrefabData(VehicleInfo info) { this._info = info; Utils.Log((object)("Creating PrefabData for " + this.ObjectName)); if (this.ObjectName == "451494281.London 1992 Stock (4 car)_Data") { int length = 3; this._info.m_trailers = new VehicleInfo.VehicleTrailer[length]; for (int index = 0; index < length; ++index) { this._info.m_trailers[index].m_info = this._info; this._info.m_trailers[index].m_invertProbability = 50; this._info.m_trailers[index].m_probability = 100; } } else if (this.ObjectName.Contains("D3S Solaris Urbino 24 '15") && this._info.m_trailers != null && this._info.m_trailers.Length != 0) { this._info.m_dampers = 0.6f; VehicleInfo loaded = PrefabCollection <VehicleInfo> .FindLoaded(this.ObjectName.Substring(0, this.ObjectName.IndexOf(".")) + ".D3S Solaris Urbino 24 '15 (II)_Data"); if ((UnityEngine.Object)loaded != (UnityEngine.Object)null) { Utils.Log((object)("Fixing " + this.ObjectName)); this._info.m_trailers[0].m_info.m_dampers = 0.6f; loaded.m_attachOffsetFront = 1.07f; loaded.m_dampers = 0.6f; this._info.m_trailers[1].m_info = loaded; this._info.m_trailers[1].m_invertProbability = 0; this._info.m_trailers[1].m_probability = 100; this.ApplyBackEngine(loaded, 0); } } if (this._info.m_trailers != null) { int length = this._info.m_trailers.Length; if (length > 0) { this._lastTrailer = this._info.m_trailers[length - 1]; this._trailerData = new PrefabData[length]; for (int index = 0; index < length; ++index) { VehicleInfo info1 = this._info.m_trailers[index].m_info; if ((UnityEngine.Object)info1 != (UnityEngine.Object)null) { this._trailerData[index] = PrefabData.CreateTrailerData(info1); } } } } this.CacheDefaults(); this.LoadPrefabData(); }
public static bool TryLoadData(out VehicleData[] data) { data = new VehicleData[CachedVehicleData.MaxVehicleCount]; byte[] data1 = SerializableDataExtension.instance.SerializableData.LoadData(CachedVehicleData._dataID); if (data1 == null) { return(false); } int index1 = 0; string empty = string.Empty; try { Utils.Log((object)"Try to load vehicle data."); string str = SerializableDataExtension.ReadString(data1, ref index1); if (string.IsNullOrEmpty(str) || str.Length != 4) { Utils.LogWarning((object)"Unknown data found."); return(false); } Utils.Log((object)("Found vehicle data version: " + str)); while (index1 < Math.Min(data1.Length, CachedVehicleData.MaxVehicleCount)) { int index2 = SerializableDataExtension.ReadInt32(data1, ref index1); if (str == "v001") { int num = (int)SerializableDataExtension.ReadByte(data1, ref index1); } data[index2].LastStopNewPassengers = SerializableDataExtension.ReadInt32(data1, ref index1); data[index2].LastStopGonePassengers = SerializableDataExtension.ReadInt32(data1, ref index1); data[index2].PassengersThisWeek = SerializableDataExtension.ReadInt32(data1, ref index1); data[index2].PassengersLastWeek = SerializableDataExtension.ReadInt32(data1, ref index1); data[index2].IncomeThisWeek = SerializableDataExtension.ReadInt32(data1, ref index1); data[index2].IncomeLastWeek = SerializableDataExtension.ReadInt32(data1, ref index1); data[index2].PassengerData = SerializableDataExtension.ReadFloatArray(data1, ref index1); data[index2].IncomeData = SerializableDataExtension.ReadFloatArray(data1, ref index1); if (str != "v001" && str != "v002") { data[index2].CurrentStop = SerializableDataExtension.ReadUInt16(data1, ref index1); } } return(true); } catch (Exception ex) { Utils.LogWarning((object)("Could not load vehicle data. " + ex.Message)); data = new VehicleData[CachedVehicleData.MaxVehicleCount]; return(false); } }
public static void Init(int maxVehicleCount) { MaxVehicleCount = maxVehicleCount; if (CachedVehicleData._isDeployed) { return; } if (!CachedVehicleData.TryLoadData(out CachedVehicleData.m_cachedVehicleData)) { Utils.Log((object)"Loading default vehicle data."); } SerializableDataExtension.instance.EventSaveData += new SerializableDataExtension.SaveDataEventHandler(CachedVehicleData.OnSaveData); CachedVehicleData._isDeployed = true; }
public override void Update() { base.Update(); if (!this.isVisible || (int)this.VehicleID == 0) { return; } string vehicleName = Singleton <VehicleManager> .instance.GetVehicleName(this.VehicleID); if (!(this._cachedName != vehicleName)) { return; } this._cachedName = vehicleName; Utils.Truncate(this._label, vehicleName, "…"); }
public override void Start() { base.Start(); this.width = this.parent.width; this.height = 27f; this.autoLayoutDirection = LayoutDirection.Horizontal; this.autoLayoutStart = LayoutStart.TopLeft; this.autoLayoutPadding = new RectOffset(4, 0, 0, 0); this.autoLayout = true; this._label = this.AddUIComponent <UILabel>(); this._label.textScale = 0.8f; this._label.font = this.Font; this._label.autoSize = false; this._label.height = this.height; this._label.width = this.width - (float)this.autoLayoutPadding.left; this._label.verticalAlignment = UIVerticalAlignment.Middle; Utils.Truncate(this._label, this._prefab.Title, "…"); }
private void ReleaseUnusedCitizenUnits() { Utils.Log((object)"Find and clear unused citizen units."); CitizenManager instance = Singleton <CitizenManager> .instance; int num = 0; for (int index = 0; index < instance.m_units.m_buffer.Length; ++index) { CitizenUnit citizenUnit = instance.m_units.m_buffer[index]; if (citizenUnit.m_flags != CitizenUnit.Flags.None && (int)citizenUnit.m_building == 0 && ((int)citizenUnit.m_vehicle == 0 && (int)citizenUnit.m_goods == 0)) { ++num; instance.m_units.m_buffer[index] = new CitizenUnit(); instance.m_units.ReleaseItem((uint)index); Utils.LogToTxt((object)string.Format("CitizenUnit #{0} - Flags: {1} - Citizens: #{2} | #{3} | #{4} | #{5} | #{6}", (object)index, (object)citizenUnit.m_flags, (object)citizenUnit.m_citizen0, (object)citizenUnit.m_citizen1, (object)citizenUnit.m_citizen2, (object)citizenUnit.m_citizen3, (object)citizenUnit.m_citizen4)); } } Utils.Log((object)("Cleared " + (object)num + " unused citizen units.")); }
public override void Update() { base.Update(); if (OptionsWrapper <Settings> .Options.HideVehicleEditor != this._hide) { this._hide = OptionsWrapper <Settings> .Options.HideVehicleEditor; this.isVisible = !this._hide; } if (OptionsWrapper <Settings> .Options.VehicleEditorPosition != this._position) { this._position = OptionsWrapper <Settings> .Options.VehicleEditorPosition; if (this.isVisible) { this.UpdatePosition(); } } if (!this._initialized) { this._publicTransportInfoViewPanel = GameObject.Find("(Library) PublicTransportInfoViewPanel").GetComponent <PublicTransportInfoViewPanel>(); if (!((UnityEngine.Object) this._publicTransportInfoViewPanel != (UnityEngine.Object)null)) { return; } this._publicTransportInfoViewPanel.component.eventVisibilityChanged += new PropertyChangedEventHandler <bool>(this.ParentVisibilityChanged); this._publicTransportInfoViewPanel.component.eventPositionChanged += new PropertyChangedEventHandler <Vector2>(this.ParentPositionChanged); this.CreatePanel(); VehicleEditor.Instance = this; this._initialized = true; } else if (this._initialized && this.isVisible && this._firstShow) { this.FirstShowInit(TransportInfo.TransportType.Bus, (VehicleInfo)null); } else { if (!this._initialized || !this.isVisible) { return; } this._rightSidePanel.Find <UILabel>("MaintenanceCostLabel").text = (Utils.ToSingle(this._rightSidePanel.Find <UITextField>("MaintenanceCost").text) * 0.01f).ToString(ColossalFramework.Globalization.Locale.Get("MONEY_FORMAT"), (IFormatProvider)LocaleManager.cultureInfo); this._rightSidePanel.Find <UILabel>("MaxSpeedLabel").text = (Utils.ToInt32(this._rightSidePanel.Find <UITextField>("MaxSpeed").text) * 5).ToString() + " " + OptionsWrapper <Settings> .Options.SpeedString; } }
private void OnApplyButtonClick(UIComponent component, UIMouseEventParameter eventParam) { if (this._selectedIndex <= -1) { return; } UITextField uiTextField1 = this._rightSidePanel.Find <UITextField>("Capacity"); UITextField uiTextField2 = this._rightSidePanel.Find <UITextField>("MaintenanceCost"); UITextField uiTextField4 = this._rightSidePanel.Find <UITextField>("MaxSpeed"); UICheckBox uiCheckBox = this._rightSidePanel.Find <UICheckBox>("EngineOnBothEnds"); PrefabData prefab = GetPrefabs()[this._selectedIndex]; int capacity = Utils.ToInt32(uiTextField1.text) / prefab.CarCount; int int32_1 = Utils.ToInt32(uiTextField2.text); int int32_3 = Utils.ToInt32(uiTextField4.text); bool isChecked = uiCheckBox.isChecked; prefab.SetValues(capacity, int32_1, int32_3, isChecked); this.UpdateBindings(); }
private static void Modify(string id, string oldValue, string newValue) { try { Dictionary <Locale.Key, string> dictionary = Utils.GetPrivate <Dictionary <Locale.Key, string> >((object)Utils.GetPrivate <Locale>((object)SingletonLite <LocaleManager> .instance, "m_Locale"), "m_LocalizedStrings"); Locale.Key key = new Locale.Key() { m_Identifier = id }; string str; if (!dictionary.TryGetValue(key, out str)) { return; } dictionary[key] = str.Replace(oldValue, newValue); } catch (Exception ex) { Utils.LogWarning((object)("Unexpected " + ex.GetType().Name + " updating localization: " + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine)); } }
private static void EnsureCitizenUnits(ushort vehicleID, ref Vehicle data, int passengerCount) { CitizenManager instance = Singleton <CitizenManager> .instance; uint num = 0; for (uint firstUnit = data.m_citizenUnits; (int)firstUnit != 0; firstUnit = instance.m_units.m_buffer[(int)firstUnit].m_nextUnit) { if ((instance.m_units.m_buffer[(int)firstUnit].m_flags & CitizenUnit.Flags.Vehicle) != CitizenUnit.Flags.None) { passengerCount -= 5; } if (passengerCount < 0) { Utils.LogToTxt((object)string.Format("ReleaseUnits for #{0}", (object)vehicleID)); instance.m_units.m_buffer[(int)num].m_nextUnit = 0U; instance.ReleaseUnits(firstUnit); return; } num = firstUnit; } if (passengerCount <= 0) { return; } Utils.LogToTxt((object)string.Format("CreateUnits for #{0}", (object)vehicleID)); uint firstUnit1 = 0; if (!instance.CreateUnits(out firstUnit1, ref Singleton <SimulationManager> .instance.m_randomizer, (ushort)0, vehicleID, 0, 0, 0, passengerCount, 0)) { return; } if ((int)num != 0) { instance.m_units.m_buffer[(int)num].m_nextUnit = firstUnit1; } else { data.m_citizenUnits = firstUnit1; } }
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(); } }
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>(); CachedNodeData.Init(); Patch(typeof(DepotAI), nameof(DepotAI.StartTransfer), DepotAIPatch.GetPrefix(), null); Patch(typeof(NetManager), nameof(NetManager.ReleaseNode), null, typeof(NetManagerPatch).GetMethod(nameof(NetManagerPatch.ReleaseNode))); //TODO: think, whether it should be pre or post CachedVehicleData.Init(); Patch(typeof(VehicleManager), "ReleaseWaterSource", null, typeof(VehicleManagerPatch).GetMethod(nameof(VehicleManagerPatch.ReleaseWaterSource))); //TODO: think, whether it should be pre or post Redirector <BusAIDetour> .Deploy(); PatchCountPassengers(typeof(BusAI)); Redirector <TrolleybusAIDetour> .Deploy(); PatchCountPassengers(typeof(TrolleybusAI)); Redirector <PassengerTrainAIDetour> .Deploy(); PatchCountPassengers(typeof(PassengerTrainAI)); Redirector <PassengerShipAIDetour> .Deploy(); PatchCountPassengers(typeof(PassengerShipAI)); Redirector <PassengerPlaneAIDetour> .Deploy(); PatchCountPassengers(typeof(PassengerPlaneAI)); Redirector <PassengerFerryAIDetour> .Deploy(); PatchCountPassengers(typeof(PassengerFerryAI)); Redirector <PassengerBlimpAIDetour> .Deploy(); PatchCountPassengers(typeof(PassengerBlimpAI)); Redirector <PassengerHelicopterAIDetour> .Deploy(); PatchCountPassengers(typeof(PassengerHelicopterAI)); Redirector <TramAIDetour> .Deploy(); PatchCountPassengers(typeof(TramAI)); Redirector <CommonBuildingAIReverseDetour> .Deploy(); Redirector <PublicTransportStopButtonDetour> .Deploy(); Redirector <PublicTransportVehicleButtonDetour> .Deploy(); Redirector <PublicTransportWorldInfoPanelDetour> .Deploy(); BuildingExtension.Init(); LineWatcher.instance.Init(); CachedTransportLineData.Init(); Redirector <TransportLineDetour> .Deploy(); 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(); } }
private void Update() { if (!this._initialized) { this._cityServiceWorldInfoPanel = GameObject.Find("(Library) CityServiceWorldInfoPanel").GetComponent <CityServiceWorldInfoPanel>(); if (!((UnityEngine.Object) this._cityServiceWorldInfoPanel != (UnityEngine.Object)null)) { return; } this.CreateStopsPanel(); this._initialized = true; } else { if (!this._initialized || !this._cityServiceWorldInfoPanel.component.isVisible) { return; } BuildingManager instance1 = Singleton <BuildingManager> .instance; ushort building = Utils.GetPrivate <InstanceID>((object)this._cityServiceWorldInfoPanel, "m_InstanceID").Building; ItemClass.SubService subService = instance1.m_buildings.m_buffer[(int)building].Info.GetSubService(); ItemClass.Service service = instance1.m_buildings.m_buffer[(int)building].Info.GetService(); ItemClass.Level level = instance1.m_buildings.m_buffer[(int)building].Info.GetClassLevel(); switch (subService) { case ItemClass.SubService.PublicTransportBus: case ItemClass.SubService.PublicTransportTours: case ItemClass.SubService.PublicTransportMetro: case ItemClass.SubService.PublicTransportTrain: case ItemClass.SubService.PublicTransportShip: case ItemClass.SubService.PublicTransportPlane: case ItemClass.SubService.PublicTransportMonorail: case ItemClass.SubService.PublicTransportTrolleybus: this._vehicleListBox.Hide(); //TODO(earalov): display depot's vehicles? Also, maybe it makes sense to display list of lines served by depot? this._stopsListBox.Show(); ushort[] numArray = PanelExtenderCityService.GetStationStops(building); BuildingInfo.SubInfo[] subBuildings = instance1.m_buildings.m_buffer[(int)building].Info.m_subBuildings; if (subBuildings != null && subBuildings.Length != 0) { Vector3 position = instance1.m_buildings.m_buffer[(int)building].m_position; building = instance1.FindBuilding(position, 100f, ItemClass.Service.PublicTransport, ItemClass.SubService.None, Building.Flags.Untouchable, Building.Flags.None); if ((int)building != 0) { ushort[] stationStops = PanelExtenderCityService.GetStationStops(building); if (stationStops.Length != 0) { numArray = ((IEnumerable <ushort>)numArray).Concat <ushort>((IEnumerable <ushort>)stationStops).ToArray <ushort>(); } } } int length = numArray.Length; if (length > 0) { this._titleLabel.text = Localization.Get("CITY_SERVICE_PANEL_TITLE_STATION_STOPS"); this._listBoxPanel.relativePosition = new Vector3(this._listBoxPanel.parent.width + 1f, VerticalOffset); this._listBoxPanel.Show(); if ((int)this._cachedBuildingID != (int)building || this._cachedStopCount != length) { this._stopsListBox.ClearItems(); for (int index = 0; index < length; ++index) { this._stopsListBox.AddItem(numArray[index], -1); } } } else { this._listBoxPanel.Hide(); } this._cachedStopCount = length; break; case ItemClass.SubService.PublicTransportTaxi: case ItemClass.SubService.PublicTransportCableCar: this._vehicleListBox.Show(); this._stopsListBox.Hide(); UIPanel uiPanel = this._cityServiceWorldInfoPanel.Find <UIPanel>("SvsVehicleTypes"); if ((UnityEngine.Object)uiPanel != (UnityEngine.Object)null) { this._listBoxPanel.relativePosition = new Vector3((float)((double)this._listBoxPanel.parent.width + (double)uiPanel.width + 2.0), VerticalOffset); } List <ushort> depotVehicles = PanelExtenderCityService.GetDepotVehicles(building); int count = depotVehicles.Count; if (count > 0) { this._titleLabel.text = Localization.Get("CITY_SERVICE_PANEL_TITLE_DEPOT_VEHICLES"); this._listBoxPanel.Show(); if ((int)this._cachedBuildingID != (int)building || this._cachedVehicleCount != count) { this._vehicleListBox.ClearItems(); PrefabData[] prefabs = VehiclePrefabs.instance.GetPrefabs(service, subService, level); VehicleManager instance2 = Singleton <VehicleManager> .instance; foreach (ushort vehicleID in depotVehicles) { VehicleInfo info = instance2.m_vehicles.m_buffer[(int)vehicleID].Info; for (int index = 0; index < prefabs.Length; ++index) { PrefabData data = prefabs[index]; if (info.name == data.ObjectName) { this._vehicleListBox.AddItem(data, vehicleID); break; } } } } } else { this._listBoxPanel.Hide(); } this._cachedVehicleCount = count; break; default: this._listBoxPanel.Hide(); break; } this._cachedBuildingID = building; } }