示例#1
0
        public void RefreshData()
        {
            Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[this.m_buildingID];

            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);

            m_districtName.text = districtName;
            if (!(b.Info.GetAI() is ShelterAI))
            {
                m_prefixesServed.relativePosition = new Vector2(340, 0);
                //prefix
                m_prefixesServed.text = TLMLineUtils.getPrefixesServedString(m_buildingID, secondary);
                DepotAI       buildingAI    = b.Info.GetAI() as DepotAI;
                List <string> prefixOptions = TLMUtils.getDepotPrefixesOptions(TransportSystemDefinition.from(secondary ? buildingAI.m_secondaryTransportInfo : buildingAI.m_transportInfo).toConfigIndex());
                prefixOptions.Add(Locale.Get("TLM_REGIONAL"));
                if (m_prefixOptions.items.Length != prefixOptions.Count)
                {
                    m_prefixOptions.items = prefixOptions.ToArray();
                    onChangePrefixSelected(m_prefixOptions.selectedIndex);
                }
            }
            m_isDirty = false;
        }
 private void updateDepotEditShortcutButton(UIComponent 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).isPrefixable())
             {
                 lines.Add(string.Format("{0}: {1}", TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(ai.m_transportInfo).toConfigIndex()), TLMLineUtils.getPrefixesServedString(buildingId, false)));
                 count++;
             }
             if (ai.m_secondaryTransportInfo != null && ai.m_maxVehicleCount2 > 0 && TransportSystemDefinition.from(ai.m_secondaryTransportInfo).isPrefixable())
             {
                 lines.Add(string.Format("{0}: {1}", TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(ai.m_secondaryTransportInfo).toConfigIndex()), TLMLineUtils.getPrefixesServedString(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;
         }
     }
 }