private void updateBuildingEditShortcutButton(UIPanel parent)
        {
            if (parent != null)
            {
                UIButton buildingEditShortcut = parent.Find <UIButton>("SVMBuildingShortcut");
                if (!buildingEditShortcut)
                {
                    buildingEditShortcut = initBuildingEditOnWorldInfoPanel(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;
                var    ssds       = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].Info);

                byte count = 0;
                foreach (var ssd in ssds)
                {
                    var maxCount = SVMBuildingUtils.GetMaxVehiclesBuilding(buildingId, ssd.vehicleType, ssd.level);
                    if (maxCount > 0)
                    {
                        count++;
                        break;
                    }
                }
                buildingEditShortcut.isVisible = count > 0;
            }
        }
Пример #2
0
        public void RefreshData()
        {
            if (Singleton <BuildingManager> .exists && transform.parent.gameObject.GetComponent <UIComponent>().isVisible)
            {
                GetComponent <UIComponent>().isVisible = true;
                Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[this.m_buildingID];
                this.m_buildingName.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("SVM_DISTRICT_NONE") : Singleton <DistrictManager> .instance.GetDistrictName(districtID);

                this.m_districtName.text = districtName;

                int count    = 0;
                int cargo    = 0;
                int capacity = 0;
                int inbound  = 0;
                int outbound = 0;
                var extstr   = SVMBuildingAIOverrideUtils.getBuildingOverrideExtensionStrict(b.Info);
                var defLevel = b.Info.m_class.m_level;
                SVMBuildingUtils.CalculateOwnVehicles(buildingId, ref b, extstr.GetManagedReasons(b.Info).Where(x => (x.Value.vehicleLevel ?? defLevel) == sysDef.level).Select(x => x.Key), ref count, ref cargo, ref capacity, ref inbound, ref outbound);

                int maxCount = SVMBuildingUtils.GetMaxVehiclesBuilding(buildingId, sysDef.vehicleType, sysDef.level);
                m_totalVehicles.prefix = count.ToString();
                m_totalVehicles.suffix = maxCount > 0x3FFF ? "∞" : maxCount.ToString();
                if (Singleton <T> .instance.GetSSD().outsideConnection)
                {
                    float angle = Vector2.zero.GetAngleToPoint(VectorUtils.XZ(b.m_position));
                    m_directionLabel.prefix = $"{angle:n1}°";
                    m_directionLabel.text   = " - ";
                    m_directionLabel.suffix = CardinalPoint.getCardinalPoint(angle).ToString();
                }
            }
        }