public static ushort[] GetStationStops(ushort buildingID) { List <ushort> stationStops = new List <ushort>(); NetManager instance = Singleton <NetManager> .instance; ushort num1 = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)buildingID].m_netNode; int num2 = 0; while ((int)num1 != 0) { if (instance.m_nodes.m_buffer[(int)num1].Info.m_class.m_layer != ItemClass.Layer.PublicTransport) { for (int index = 0; index < 8; ++index) { ushort segment = instance.m_nodes.m_buffer[(int)num1].GetSegment(index); if ((int)segment != 0 && (int)instance.m_segments.m_buffer[(int)segment].m_startNode == (int)num1) { PanelExtenderCityService.CalculateLanes(instance.m_segments.m_buffer[(int)segment].m_lanes, ref stationStops); } } } num1 = instance.m_nodes.m_buffer[(int)num1].m_nextBuildingNode; if (++num2 > 32768) { CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + System.Environment.StackTrace); break; } } return(stationStops.ToArray()); }
private void ProcessNodes(System.Action <ushort> processNode) { NetManager instance = Singleton <NetManager> .instance; bool flag = false; NetNode netNode1 = instance.m_nodes.m_buffer[(int)this.m_InstanceID.NetNode]; Vector3 position = netNode1.m_position; ItemClass.SubService subService = netNode1.Info.m_class.m_subService; ushort building = Singleton <BuildingManager> .instance.FindBuilding(position, 100f, ItemClass.Service.PublicTransport, subService, Building.Flags.Active, Building.Flags.Untouchable); if ((int)building != 0) { ushort[] stationStops = PanelExtenderCityService.GetStationStops(building); if (stationStops.Length != 0 && ((IEnumerable <ushort>)stationStops).Contains <ushort>(this.m_InstanceID.NetNode)) { flag = true; for (int index = 0; index < stationStops.Length; ++index) { processNode(stationStops[index]); } } } if (flag) { return; } for (int index = 0; index < 32768; ++index) { NetNode netNode2 = instance.m_nodes.m_buffer[index]; if (netNode2.m_flags != NetNode.Flags.None && (int)netNode2.m_transportLine != 0 && position == netNode2.m_position) { processNode((ushort)index); } } }
private static void CalculateLanes(uint firstLane, ref List <ushort> stationStops) { NetManager instance = Singleton <NetManager> .instance; uint num1 = firstLane; int num2 = 0; while ((int)num1 != 0) { ushort nodes = instance.m_lanes.m_buffer[(int)(uint)(UIntPtr)num1].m_nodes; if ((int)nodes != 0) { PanelExtenderCityService.CalculateLaneNodes(nodes, ref stationStops); } num1 = instance.m_lanes.m_buffer[(int)(uint)(UIntPtr)num1].m_nextLane; if (++num2 > 262144) { CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + System.Environment.StackTrace); break; } } }
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(); switch (subService) { case ItemClass.SubService.PublicTransportBus: case ItemClass.SubService.PublicTransportMetro: case ItemClass.SubService.PublicTransportTrain: case ItemClass.SubService.PublicTransportShip: case ItemClass.SubService.PublicTransportPlane: this._vehicleListBox.Hide(); 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, 0.0f); 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: 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), 0.0f); } 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(subService); 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; } }