public void RefreshData() { if (Singleton <BuildingManager> .exists) { m_prefixesServedList = TLMDepotAI.getPrefixesServedByDepot(m_buildingID, secondary); if (m_prefixesServedList == null) { GameObject.Destroy(gameObject); return; } bool isRowVisible; isRowVisible = TLMPublicTransportDetailPanel.instance.isOnCurrentPrefixFilter(m_prefixesServedList); if (!isRowVisible) { GetComponent <UIComponent>().isVisible = false; return; } GetComponent <UIComponent>().isVisible = true; Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[this.m_buildingID]; this.m_depotName.text = Singleton <BuildingManager> .instance.GetBuildingName(this.m_buildingID, default(InstanceID)); byte districtID = Singleton <DistrictManager> .instance.GetDistrict(b.m_position); string districtName = districtID == 0 ? Locale.Get("TLM_DISTRICT_NONE") : Singleton <DistrictManager> .instance.GetDistrictName(districtID); this.m_districtName.text = districtName; //prefix this.m_prefixesServed.text = TLMLineUtils.getPrefixesServedAbstract(this.m_buildingID, secondary); DepotAI buildingAI = b.Info.GetAI() as DepotAI; List <string> prefixOptions = TLMUtils.getDepotPrefixesOptions(TLMCW.getConfigIndexForTransportInfo(secondary ? buildingAI.m_secondaryTransportInfo : buildingAI.m_transportInfo)); prefixOptions.Add(Locale.Get("TLM_REGIONAL")); if (this.m_prefixOptions.items.Length != prefixOptions.Count) { this.m_prefixOptions.items = prefixOptions.ToArray(); onChangePrefixSelected(m_prefixOptions.selectedIndex); } } }
private void updateDepotEditShortcutButton(UIPanel parent) { if (parent != null) { UIButton depotShortcut = parent.Find <UIButton>("TLMDepotShortcut"); if (!depotShortcut) { depotShortcut = initDepotShortcutOnWorldInfoPanel(parent); } var prop = typeof(WorldInfoPanel).GetField("m_InstanceID", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); ushort buildingId = ((InstanceID)(prop.GetValue(parent.gameObject.GetComponent <WorldInfoPanel>()))).Building; if (Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].Info.GetAI() is DepotAI ai) { byte count = 0; List <string> lines = new List <string>(); if (ai.m_transportInfo != null && ai.m_maxVehicleCount > 0 && TransportSystemDefinition.from(ai.m_transportInfo) != null) { lines.Add(string.Format("{0}: {1}", TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(ai.m_transportInfo).toConfigIndex()), TLMLineUtils.getPrefixesServedAbstract(buildingId, false))); count++; } if (ai.m_secondaryTransportInfo != null && ai.m_maxVehicleCount2 > 0 && TransportSystemDefinition.from(ai.m_secondaryTransportInfo) != null) { lines.Add(string.Format("{0}: {1}", TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(ai.m_secondaryTransportInfo).toConfigIndex()), TLMLineUtils.getPrefixesServedAbstract(buildingId, true))); count++; } depotShortcut.isVisible = count > 0; if (depotShortcut.isVisible) { UILabel label = depotShortcut.GetComponentInChildren <UILabel>(); label.text = string.Join("\n", lines.ToArray()); } } else { depotShortcut.isVisible = false; } } }