public static void Postfix(CityServiceWorldInfoPanel __instance)
        {
            InstanceID instanceID = (InstanceID)__instance.GetType()
                                    .GetField("m_InstanceID", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);

            var building = BuildingManager.instance.m_buildings.m_buffer[instanceID.Building].Info;


            if (building.GetService() == ItemClass.Service.FireDepartment ||
                building.GetService() == ItemClass.Service.Garbage ||
                building.GetService() == ItemClass.Service.HealthCare ||
                building.GetService() == ItemClass.Service.Disaster ||
                building.GetService() == ItemClass.Service.PoliceDepartment)
            {
                return;
            }

            if (BuildingHelper.DisplayDistrictsButton(building.m_buildingAI))
            {
                return;
            }

            var toggleButton = __instance.component.Find("ServiceRestrictionToggleButton") as UIButton;

            if (toggleButton == null)
            {
                return;
            }
            toggleButton.isEnabled = false;
            toggleButton.tooltip   = "Service Restrictions does not currently cover this building.";
        }
        /// <summary>
        /// Adds button to access building details from building info panels.
        /// </summary>
        internal static void AddInfoPanelButton()
        {
            // Zoned building panel - get parent panel and add button.
            ZonedBuildingWorldInfoPanel infoPanel = UIView.library.Get <ZonedBuildingWorldInfoPanel>(typeof(ZonedBuildingWorldInfoPanel).Name);

            zonedButton             = UIControls.AddButton(infoPanel.component, infoPanel.component.width - 133f - 10, 120, Translations.Translate("RPR_REALPOP"), 133f, 19.5f, 0.65f);
            zonedButton.textPadding = new RectOffset(2, 2, 4, 0);

            // Just in case other mods are interfering.
            zonedButton.Enable();

            // Event handler.
            zonedButton.eventClick += (control, clickEvent) =>
            {
                // Select current building in the building details panel and show.
                Open(InstanceManager.GetPrefabInfo(WorldInfoPanel.GetCurrentInstanceID()) as BuildingInfo);
            };

            // Service building panel - get parent panel and add button.
            CityServiceWorldInfoPanel servicePanel = UIView.library.Get <CityServiceWorldInfoPanel>(typeof(CityServiceWorldInfoPanel).Name);

            serviceButton             = UIControls.AddButton(servicePanel.component, servicePanel.component.width - 133f - 10, 120, Translations.Translate("RPR_REALPOP"), 133f, 19.5f, 0.65f);
            serviceButton.textPadding = new RectOffset(2, 2, 4, 0);

            // Event handler.
            serviceButton.eventClick += (control, clickEvent) =>
            {
                // Select current building in the building details panel and show.
                Open(InstanceManager.GetPrefabInfo(WorldInfoPanel.GetCurrentInstanceID()) as BuildingInfo);
            };
        }
        private void AddPanel()
        {
            if (_isPanelInitialized)
            {
                return;
            }

            ServiceInfoPanel = GameObject.Find("(Library) CityServiceWorldInfoPanel")
                               .GetComponent <CityServiceWorldInfoPanel>();

            if (ServiceInfoPanel == null)
            {
                return;
            }

            AddButton(ServiceInfoPanel, out _toggleButton, new Vector3(257f, 15f));

            ServiceInfoPanel.component.eventIsEnabledChanged += (component, value) =>
            {
                if (!value)
                {
                    if (RestrictedDistrictsPanel.Instance != null)
                    {
                        if (RestrictedDistrictsPanel.Instance.CampusPanelWrapper != null &&
                            RestrictedDistrictsPanel.Instance.CampusPanelWrapper.isVisible)
                        {
                            RestrictedDistrictsPanel.Instance.CampusPanelWrapper.isVisible = false;
                            UIUtils.DeepDestroy(RestrictedDistrictsPanel.Instance.CampusPanelWrapper);
                        }

                        if (RestrictedDistrictsPanel.Instance.ParkPanelWrapper != null &&
                            RestrictedDistrictsPanel.Instance.ParkPanelWrapper.isVisible)
                        {
                            RestrictedDistrictsPanel.Instance.ParkPanelWrapper.isVisible = false;
                            UIUtils.DeepDestroy(RestrictedDistrictsPanel.Instance.ParkPanelWrapper);
                        }

                        if (RestrictedDistrictsPanel.Instance.IndustriesPanelWrapper != null &&
                            RestrictedDistrictsPanel.Instance.IndustriesPanelWrapper.isVisible)
                        {
                            RestrictedDistrictsPanel.Instance.IndustriesPanelWrapper.isVisible = false;
                            UIUtils.DeepDestroy(RestrictedDistrictsPanel.Instance.IndustriesPanelWrapper);
                        }
                    }

                    if (RestrictedDistrictsPanelWrapper != null)
                    {
                        RestrictedDistrictsPanelWrapper.isVisible = false;
                        UIUtils.DeepDestroy(RestrictedDistrictsPanelWrapper);
                    }
                }
            };

            _isPanelInitialized = true;
        }
Exemple #4
0
        public static void OnSetTarget(BuildingWorldInfoPanel thisPanel)
        {
            FieldInfo m_TimeInfo = typeof(BuildingWorldInfoPanel).GetField("m_Time", BindingFlags.NonPublic | BindingFlags.Instance);
            float?    m_Time     = m_TimeInfo.GetValue(thisPanel) as float?;

            if (m_Time != null)
            {
                m_NameField = thisPanel.Find <UITextField>("BuildingName");

                if (m_NameField != null)
                {
                    if (originalNameWidth == -1)
                    {
                        originalNameWidth = m_NameField.width;
                    }

                    m_NameField.text = GetName(thisPanel);
                    m_Time           = 0.0f;

                    CityServiceWorldInfoPanel servicePanel = thisPanel as CityServiceWorldInfoPanel;

                    if (servicePanel != null)
                    {
                        LoggingWrapper.Log("Adding event UI to service panel.");
                        AddEventUI(servicePanel);

                        if (!translationSetUp)
                        {
                            translationSetUp = true;

                            CimTools.CimToolsHandler.CimToolBase.Translation.OnLanguageChanged += delegate(string languageIdentifier)
                            {
                                UIButton createEventButton = null;

                                try { createEventButton = servicePanel.Find <UIButton>("CreateEventButton"); } catch { }

                                if (createEventButton != null)
                                {
                                    createEventButton.tooltip = CimTools.CimToolsHandler.CimToolBase.Translation.GetTranslation("Event_CreateUserEvent");
                                    createEventButton.RefreshTooltip();
                                }
                            };
                        }
                    }
                }
                else
                {
                    Debug.LogError("Couldn't set the m_NameField parameter of the BuildingWorldInfoPanel");
                }
            }
            else
            {
                Debug.LogError("Couldn't set the m_Time parameter of the BuildingWorldInfoPanel");
            }
        }
        public void Awake()
        {
            zonedPanelUi = UIView.Find<UIPanel>("(Library) ZonedBuildingWorldInfoPanel");
            zonedPanelUi.eventVisibilityChanged += ZonedPanel_eventVisibilityChanged;

            servicePanelUi = UIView.Find<UIPanel>("(Library) CityServiceWorldInfoPanel");
            servicePanelUi.eventVisibilityChanged += ServicePanel_eventVisibilityChanged;
            servicePanelUi.size = zonedPanelUi.size;
            servicePanel = servicePanelUi.gameObject.transform.GetComponentInChildren<CityServiceWorldInfoPanel>();
            zonedPanel = zonedPanelUi.gameObject.transform.GetComponentInChildren<ZonedBuildingWorldInfoPanel>();
        }
        public void Awake()
        {
            zonedPanelUi = GameObject.Find("(Library) ZonedBuildingWorldInfoPanel").GetComponent <UIPanel>();
            zonedPanelUi.eventVisibilityChanged += ZonedPanel_eventVisibilityChanged;

            servicePanelUi = GameObject.Find("(Library) CityServiceWorldInfoPanel").GetComponent <UIPanel>();
            servicePanelUi.eventVisibilityChanged += ServicePanel_eventVisibilityChanged;
            servicePanelUi.size = zonedPanelUi.size;
            servicePanel        = servicePanelUi.gameObject.transform.GetComponentInChildren <CityServiceWorldInfoPanel>();
            zonedPanel          = zonedPanelUi.gameObject.transform.GetComponentInChildren <ZonedBuildingWorldInfoPanel>();
        }
        private void AddPanelButton()
        {
            if (!inizializedButton)
            {
                ServiceBuildingInfoPanel = GameObject.Find("(Library) CityServiceWorldInfoPanel").GetComponent <CityServiceWorldInfoPanel>();

                if (ServiceBuildingInfoPanel != null)
                {
                    AddBuildingPanelControls(ServiceBuildingInfoPanel, out customizeButton, new Vector3(-7f, 43f, 0f));
                    inizializedButton = true;
                }
            }
        }
        private bool FindComponents()
        {
            if (_panel != null && _fmuCheckBox != null)
            {
                return(true);
            }

            _panel = UIView.library.Get <CityServiceWorldInfoPanel>(typeof(CityServiceWorldInfoPanel).Name);
            if (_panel == null)
            {
                return(false);
            }

            _fmuCheckBox = _panel.component.Find <UICheckBox>("testFMU");
            return(_fmuCheckBox != null);
        }
Exemple #9
0
        public static void Postfix(CityServiceWorldInfoPanel __instance)
        {
            var m_fishFarmAI             = (FishFarmAI)typeof(CityServiceWorldInfoPanel).GetField("m_fishFarmAI", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var m_outputBuffer           = (UIProgressBar)typeof(CityServiceWorldInfoPanel).GetField("m_outputBuffer", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var m_outputLabel            = (UILabel)typeof(CityServiceWorldInfoPanel).GetField("m_outputLabel", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var m_arrow3                 = (UISprite)typeof(CityServiceWorldInfoPanel).GetField("m_arrow3", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var m_outputSprite           = (UISprite)typeof(CityServiceWorldInfoPanel).GetField("m_outputSprite", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var m_ShowIndustryInfoButton = (UIButton)typeof(CityServiceWorldInfoPanel).GetField("m_ShowIndustryInfoButton", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);

            if (m_fishFarmAI != null)
            {
                m_outputBuffer.progressColor = IndustryWorldInfoPanel.instance.GetResourceColor(m_fishFarmAI.m_outputResource);
                string text = Locale.Get("WAREHOUSEPANEL_RESOURCE", m_fishFarmAI.m_outputResource.ToString());
                m_outputLabel.text                 = text;
                m_arrow3.tooltip                   = StringUtils.SafeFormat(Locale.Get("INDUSTRYBUILDING_EXTRACTINGTOOLTIP"), text);
                m_outputSprite.spriteName          = IndustryWorldInfoPanel.ResourceSpriteName(m_fishFarmAI.m_outputResource, false);
                m_ShowIndustryInfoButton.isVisible = false;
            }
        }
Exemple #10
0
        public void Update()
        {
            if (!_initialized)
            {
                var go = GameObject.Find("(Library) CityServiceWorldInfoPanel");
                if (go == null)
                {
                    return;
                }

                var infoPanel = go.GetComponent <CityServiceWorldInfoPanel>();
                if (infoPanel == null)
                {
                    return;
                }

                _cityServiceInfoPanel = infoPanel;
                m_dropdownResource    = Utils.UIUtils.CreateDropDown(_cityServiceInfoPanel.component);
                m_dropdownResource.relativePosition = new Vector3(105, 267);
                m_dropdownResource.width            = 250;
                m_dropdownMode = Utils.UIUtils.CreateDropDown(_cityServiceInfoPanel.component);
                m_dropdownMode.relativePosition = new Vector3(110 + m_dropdownResource.width, 267);
                m_dropdownMode.width            = 120;
                RefreshDropdownLists();
                this.m_dropdownResource.eventSelectedIndexChanged += OnDropdownResourceChanged;
                this.m_dropdownMode.eventSelectedIndexChanged     += OnDropdownModeChanged;
                _initialized = true;
            }

            if (!_cityServiceInfoPanel.component.isVisible)
            {
                m_dropdownResource.ClosePopup();
                m_dropdownMode.ClosePopup();
                return;
            }

            SetUpSwapButton();
        }
        private void Update()
        {
            if (!_initialized)
            {
                _cityServiceWorldInfoPanel = GameObject.Find("(Library) CityServiceWorldInfoPanel").GetComponent <CityServiceWorldInfoPanel>();
                if (!(_cityServiceWorldInfoPanel != null))
                {
                    return;
                }
                CreatePrefabPanel();
                _initialized = true;
            }
            else
            {
                if (!_initialized || !_cityServiceWorldInfoPanel.component.isVisible)
                {
                    return;
                }
                bool canSelectVehicle;
                var  buildingId   = Utils.GetPrivate <InstanceID>(_cityServiceWorldInfoPanel, "m_InstanceID").Building;
                var  buffer       = Singleton <BuildingManager> .instance.m_buildings.m_buffer;
                var  building     = buffer[buildingId];
                var  buildingInfo = building.Info;
                var  itemClass    = buildingInfo.m_class;

                if (itemClass.m_service == ItemClass.Service.Water && itemClass.m_level == ItemClass.Level.Level1 && buildingInfo.m_buildingAI is WaterFacilityAI wf && wf.m_pumpingVehicles > 0)
                {
                    canSelectVehicle = true;
                    if (_cachedItemClass != itemClass)
                    {
                        _prefabPanel.relativePosition = new Vector3(_prefabPanel.parent.width + 1f, VerticalOffset);
                        _headerLabel.text             = "Vehicle types";
                        PopulateVehicleListBox(itemClass.m_service, itemClass.m_subService, itemClass.m_level, VehicleInfo.VehicleType.None);
                        _cachedItemClass = itemClass;
                    }
                }
        private void AddButton(CityServiceWorldInfoPanel infoPanel, out UIButton button, Vector3 offset)
        {
            button = UIUtils.CreateToggleButton(infoPanel.component, offset, UIAlignAnchor.BottomLeft, (component, e) =>
            {
                InstanceID instanceID = (InstanceID)infoPanel.GetType()
                                        .GetField("m_InstanceID", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(infoPanel);


                if (RestrictedDistrictsPanelWrapper == null || instanceID.Building != SelectedBuildingID)
                {
                    RestrictedDistrictsPanelWrapper = instanceID.Building.GenerateDistrictsPanelWrapper();
                }
                else
                {
                    RestrictedDistrictsPanelWrapper.isVisible = false;
                    UIUtils.DeepDestroy(RestrictedDistrictsPanelWrapper);
                }

                if (component.hasFocus)
                {
                    component.Unfocus();
                }
            });
        }
Exemple #13
0
 static void Postfix(CityServiceWorldInfoPanel __instance)
 {
     Painter.instance.IsPanelVisible = true;
     Painter.instance.BuildingID     = ((InstanceID)__instance.GetType().GetField("m_InstanceID", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance)).Building;
     Painter.instance.ColorFields[PanelType.Service].selectedColor = Painter.instance.GetColor();
 }
Exemple #14
0
        private void AddPanelButtons()
        {
            if (_isButtonInitialized)
            {
                return;
            }

            ServiceBuildingPanel = GameObject.Find("(Library) CityServiceWorldInfoPanel")
                                   .GetComponent <CityServiceWorldInfoPanel>();

            if (ServiceBuildingPanel == null)
            {
                return;
            }

            var defaultPosition = new Vector3(160f, 5f, 0f);

            if (ModToolsCompatibilityPatch.IsModToolsActive() &&
                ModToolsCompatibilityPatch.AreGamePanelExtensionsActive())
            {
                defaultPosition = new Vector3(160, -75f, 0f);
            }

            AddDefaultBuildingPropertiesButton(ServiceBuildingPanel, out _customizeItExtendedButton,
                                               defaultPosition);

            WarehousePanel = GameObject.Find("(Library) WarehouseWorldInfoPanel")
                             .GetComponent <WarehouseWorldInfoPanel>();

            if (WarehousePanel == null)
            {
                return;
            }

            AddWarehouseBuildingPropertiesButton(WarehousePanel, out _warehouseButton, new Vector3(68f, -35f, 0f));


            UniqueFactoryWorldInfoPanel = GameObject.Find("(Library) UniqueFactoryWorldInfoPanel")
                                          .GetComponent <UniqueFactoryWorldInfoPanel>();

            if (UniqueFactoryWorldInfoPanel == null)
            {
                return;
            }

            AddUniqueFactoriesBuildingPropertiesButton(UniqueFactoryWorldInfoPanel, out _uniqueFactoryButton,
                                                       new Vector3(25f, -90f, 0f));

            ZoneBuildingPanel = GameObject.Find("(Library) ZonedBuildingWorldInfoPanel")
                                .GetComponent <ZonedBuildingWorldInfoPanel>();

            if (CustomizeItExtendedMod.DebugMode)
            {
                AddBuildingInformationButton(ZoneBuildingPanel, out _zonedInfoButton, new Vector3(120f, 5f, 0f));
            }

            ShelterInfoPanel = GameObject.Find("(Library) ShelterWorldInfoPanel").GetComponent <ShelterWorldInfoPanel>();

            Vector3 shelterPos = new Vector3(160f, 257f, 0f);


            AddDefaultBuildingPropertiesButton(ShelterInfoPanel, out _shelterInfoButton, new Vector3(160f, -231f, 0f));

            _isButtonInitialized = true;
        }
        void Update()
        {
            if (!initializedZonedBuildingsPanel)
            {
                sceneExplorer = FindObjectOfType<SceneExplorer>();

                buildingsBufferRefChain = new ReferenceChain();
                buildingsBufferRefChain = buildingsBufferRefChain.Add(BuildingManager.instance.gameObject);
                buildingsBufferRefChain = buildingsBufferRefChain.Add(BuildingManager.instance);
                buildingsBufferRefChain = buildingsBufferRefChain.Add(typeof(BuildingManager).GetField("m_buildings"));
                buildingsBufferRefChain = buildingsBufferRefChain.Add(typeof(Array16<Building>).GetField("m_buffer"));

                zonedBuildingInfoPanel = GameObject.Find("(Library) ZonedBuildingWorldInfoPanel").GetComponent<ZonedBuildingWorldInfoPanel>();
                if (zonedBuildingInfoPanel != null)
                {
                    AddBuildingPanelControls(zonedBuildingInfoPanel, out zonedBuildingAssetNameLabel,
                        out zonedBuildingShowExplorerButton, new Vector3(-8.0f, 100.0f, 0.0f),
                        out zonedBuildingDumpMeshTextureButton, new Vector3(-8.0f, 132.0f, 0.0f)
                        );
                    initializedZonedBuildingsPanel = true;
                }
            }

            if (!initializedServiceBuildingsPanel)
            {
                sceneExplorer = FindObjectOfType<SceneExplorer>();
                serviceBuildingInfoPanel = GameObject.Find("(Library) CityServiceWorldInfoPanel").GetComponent<CityServiceWorldInfoPanel>();
                if (serviceBuildingInfoPanel != null)
                {
                    AddBuildingPanelControls(serviceBuildingInfoPanel, out serviceBuildingAssetNameLabel,
                        out serviceBuildingShowExplorerButton, new Vector3(-8.0f, 100.0f, 0.0f),
                        out serviceBuildingDumpMeshTextureButton, new Vector3(-8.0f, 132.0f, 0.0f)
                        );
                    initializedServiceBuildingsPanel = true;
                }
            }

            if (!initializedCitizenVehiclePanel)
            {
                sceneExplorer = FindObjectOfType<SceneExplorer>();

                vehiclesBufferRefChain = new ReferenceChain();
                vehiclesBufferRefChain = vehiclesBufferRefChain.Add(VehicleManager.instance.gameObject);
                vehiclesBufferRefChain = vehiclesBufferRefChain.Add(VehicleManager.instance);
                vehiclesBufferRefChain = vehiclesBufferRefChain.Add(typeof(VehicleManager).GetField("m_vehicles"));
                vehiclesBufferRefChain = vehiclesBufferRefChain.Add(typeof(Array16<Vehicle>).GetField("m_buffer"));

                vehiclesParkedBufferRefChain = new ReferenceChain();
                vehiclesParkedBufferRefChain = vehiclesParkedBufferRefChain.Add(VehicleManager.instance.gameObject);
                vehiclesParkedBufferRefChain = vehiclesParkedBufferRefChain.Add(VehicleManager.instance);
                vehiclesParkedBufferRefChain = vehiclesParkedBufferRefChain.Add(typeof(VehicleManager).GetField("m_parkedVehicles"));
                vehiclesParkedBufferRefChain = vehiclesParkedBufferRefChain.Add(typeof(Array16<VehicleParked>).GetField("m_buffer"));

                citizenVehicleInfoPanel = GameObject.Find("(Library) CitizenVehicleWorldInfoPanel").GetComponent<CitizenVehicleWorldInfoPanel>();
                if (citizenVehicleInfoPanel != null)
                {
                    AddVehiclePanelControls(
                        citizenVehicleInfoPanel,
                        out citizenVehicleAssetNameLabel,
                        out citizenVehicleShowExplorerButton,
                        out citizenVehicleDumpTextureMeshButton
                        );
                    initializedCitizenVehiclePanel = true;
                }
            }

            if (!initializedCityServiceVehiclePanel)
            {
                sceneExplorer = FindObjectOfType<SceneExplorer>();

                cityServiceVehicleInfoPanel = GameObject.Find("(Library) CityServiceVehicleWorldInfoPanel").GetComponent<CityServiceVehicleWorldInfoPanel>();
                if (cityServiceVehicleInfoPanel != null)
                {
                    AddVehiclePanelControls(
                        cityServiceVehicleInfoPanel,
                        out cityServiceVehicleAssetNameLabel,
                        out cityServiceVehicleShowExplorerButton,
                        out cityServiceVehicleDumpTextureMeshButton);
                    initializedCityServiceVehiclePanel = true;
                }
            }

            if (!initializedPublicTransportVehiclePanel)
            {
                sceneExplorer = FindObjectOfType<SceneExplorer>();

                publicTransportVehicleInfoPanel = GameObject.Find("(Library) PublicTransportVehicleWorldInfoPanel").GetComponent<PublicTransportVehicleWorldInfoPanel>();
                if (publicTransportVehicleInfoPanel != null)
                {
                    AddVehiclePanelControls(
                        publicTransportVehicleInfoPanel,
                        out publicTransportVehicleAssetNameLabel,
                        out publicTransportVehicleShowExplorerButton,
                        out publicTransportVehicleDumpTextureMeshButton);
                    initializedPublicTransportVehiclePanel = true;
                }
            }

            if (zonedBuildingInfoPanel.component.isVisible)
            {
                InstanceID instance = Util.GetPrivate<InstanceID>(zonedBuildingInfoPanel, "m_InstanceID");
                var building = BuildingManager.instance.m_buildings.m_buffer[instance.Building];
                zonedBuildingAssetNameLabel.text = "AssetName: " + building.Info.name;
            }

            if (serviceBuildingInfoPanel.component.isVisible)
            {
                InstanceID instance = Util.GetPrivate<InstanceID>(serviceBuildingInfoPanel, "m_InstanceID");
                var building = BuildingManager.instance.m_buildings.m_buffer[instance.Building];
                serviceBuildingAssetNameLabel.text = "AssetName: " + building.Info.name;
            }

            if (citizenVehicleInfoPanel.component.isVisible)
            {
                InstanceID instance = Util.GetPrivate<InstanceID>(citizenVehicleInfoPanel, "m_InstanceID");

                if (instance.Vehicle == 0)
                {
                    var vehicle = VehicleManager.instance.m_parkedVehicles.m_buffer[instance.ParkedVehicle];
                    citizenVehicleAssetNameLabel.text = "AssetName: " + vehicle.Info.name;
                }
                else
                {
                    var vehicle = VehicleManager.instance.m_vehicles.m_buffer[instance.Vehicle];
                    citizenVehicleAssetNameLabel.text = "AssetName: " + vehicle.Info.name;
                }
            }

            if (cityServiceVehicleInfoPanel.component.isVisible)
            {
                InstanceID instance = Util.GetPrivate<InstanceID>(cityServiceVehicleInfoPanel, "m_InstanceID");

                if (instance.Vehicle == 0)
                {
                    var vehicle = VehicleManager.instance.m_parkedVehicles.m_buffer[instance.ParkedVehicle];
                    cityServiceVehicleAssetNameLabel.text = "AssetName: " + vehicle.Info.name;
                }
                else
                {
                    var vehicle = VehicleManager.instance.m_vehicles.m_buffer[instance.Vehicle];
                    cityServiceVehicleAssetNameLabel.text = "AssetName: " + vehicle.Info.name;
                }
            }

            if (publicTransportVehicleInfoPanel.component.isVisible)
            {
                InstanceID instance = Util.GetPrivate<InstanceID>(publicTransportVehicleInfoPanel, "m_InstanceID");

                if (instance.Vehicle == 0)
                {
                    var vehicle = VehicleManager.instance.m_parkedVehicles.m_buffer[instance.ParkedVehicle];
                    publicTransportVehicleAssetNameLabel.text = "AssetName: " + vehicle.Info.name;
                }
                else
                {
                    var vehicle = VehicleManager.instance.m_vehicles.m_buffer[instance.Vehicle];
                    publicTransportVehicleAssetNameLabel.text = "AssetName: " + vehicle.Info.name;
                }
            }
        }
Exemple #16
0
        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;
            }
        }
Exemple #17
0
        private void Initialize()
        {
            if (!initializedZonedBuildingsPanel)
            {
                sceneExplorer = FindObjectOfType <SceneExplorer>();

                buildingsBufferRefChain = new ReferenceChain()
                                          .Add(BuildingManager.instance.gameObject)
                                          .Add(BuildingManager.instance)
                                          .Add(typeof(BuildingManager).GetField("m_buildings"))
                                          .Add(typeof(Array16 <Building>).GetField("m_buffer"));

                zonedBuildingInfoPanel =
                    GameObject.Find("(Library) ZonedBuildingWorldInfoPanel").GetComponent <ZonedBuildingWorldInfoPanel>();
                if (zonedBuildingInfoPanel != null)
                {
                    AddBuildingPanelControls(zonedBuildingInfoPanel, out zonedBuildingAssetNameLabel,
                                             out zonedBuildingShowExplorerButton, new Vector3(-8.0f, 100.0f, 0.0f),
                                             out zonedBuildingDumpMeshTextureButton, new Vector3(-8.0f, 132.0f, 0.0f)
                                             );
                    initializedZonedBuildingsPanel = true;
                }
            }

            if (!initializedServiceBuildingsPanel)
            {
                sceneExplorer            = FindObjectOfType <SceneExplorer>();
                serviceBuildingInfoPanel =
                    GameObject.Find("(Library) CityServiceWorldInfoPanel").GetComponent <CityServiceWorldInfoPanel>();
                if (serviceBuildingInfoPanel != null)
                {
                    AddBuildingPanelControls(serviceBuildingInfoPanel, out serviceBuildingAssetNameLabel,
                                             out serviceBuildingShowExplorerButton, new Vector3(-8.0f, 175.0f, 0.0f),
                                             out serviceBuildingDumpMeshTextureButton, new Vector3(-8.0f, 200.0f, 0.0f)
                                             );
                    initializedServiceBuildingsPanel = true;
                }
            }

            if (!initializedCitizenVehiclePanel)
            {
                sceneExplorer = FindObjectOfType <SceneExplorer>();

                vehiclesBufferRefChain = new ReferenceChain()
                                         .Add(VehicleManager.instance.gameObject)
                                         .Add(VehicleManager.instance)
                                         .Add(typeof(VehicleManager).GetField("m_vehicles"))
                                         .Add(typeof(Array16 <Vehicle>).GetField("m_buffer"));

                vehiclesParkedBufferRefChain = new ReferenceChain()
                                               .Add(VehicleManager.instance.gameObject)
                                               .Add(VehicleManager.instance)
                                               .Add(typeof(VehicleManager).GetField("m_parkedVehicles"))
                                               .Add(typeof(Array16 <VehicleParked>).GetField("m_buffer"));

                citizenVehicleInfoPanel =
                    GameObject.Find("(Library) CitizenVehicleWorldInfoPanel").GetComponent <CitizenVehicleWorldInfoPanel>();
                if (citizenVehicleInfoPanel != null)
                {
                    AddVehiclePanelControls(
                        citizenVehicleInfoPanel,
                        out citizenVehicleAssetNameLabel,
                        out citizenVehicleShowExplorerButton,
                        out citizenVehicleDumpTextureMeshButton
                        );
                    initializedCitizenVehiclePanel = true;
                }
            }

            if (!initializedCityServiceVehiclePanel)
            {
                sceneExplorer = FindObjectOfType <SceneExplorer>();

                cityServiceVehicleInfoPanel =
                    GameObject.Find("(Library) CityServiceVehicleWorldInfoPanel")
                    .GetComponent <CityServiceVehicleWorldInfoPanel>();
                if (cityServiceVehicleInfoPanel != null)
                {
                    AddVehiclePanelControls(
                        cityServiceVehicleInfoPanel,
                        out cityServiceVehicleAssetNameLabel,
                        out cityServiceVehicleShowExplorerButton,
                        out cityServiceVehicleDumpTextureMeshButton);
                    initializedCityServiceVehiclePanel = true;
                }
            }

            if (!initializedPublicTransportVehiclePanel)
            {
                sceneExplorer = FindObjectOfType <SceneExplorer>();

                publicTransportVehicleInfoPanel =
                    GameObject.Find("(Library) PublicTransportVehicleWorldInfoPanel")
                    .GetComponent <PublicTransportVehicleWorldInfoPanel>();
                if (publicTransportVehicleInfoPanel != null)
                {
                    AddVehiclePanelControls(
                        publicTransportVehicleInfoPanel,
                        out publicTransportVehicleAssetNameLabel,
                        out publicTransportVehicleShowExplorerButton,
                        out publicTransportVehicleDumpTextureMeshButton);
                    initializedPublicTransportVehiclePanel = true;
                }
            }

            if (!initializedAnimalPanel)
            {
                citizenInstancesBufferRefChain = new ReferenceChain()
                                                 .Add(CitizenManager.instance.gameObject)
                                                 .Add(CitizenManager.instance)
                                                 .Add(typeof(CitizenManager).GetField("m_instances"))
                                                 .Add(typeof(Array16 <CitizenInstance>).GetField("m_buffer"));
                citizensBufferRefChain = new ReferenceChain()
                                         .Add(CitizenManager.instance.gameObject)
                                         .Add(CitizenManager.instance)
                                         .Add(typeof(CitizenManager).GetField("m_citizens"))
                                         .Add(typeof(Array32 <Citizen>).GetField("m_buffer"));
                citizensUnitsBufferRefChain = new ReferenceChain()
                                              .Add(CitizenManager.instance.gameObject)
                                              .Add(CitizenManager.instance)
                                              .Add(typeof(CitizenManager).GetField("m_units"))
                                              .Add(typeof(Array32 <CitizenUnit>).GetField("m_buffer"));

                sceneExplorer   = FindObjectOfType <SceneExplorer>();
                animalInfoPanel = GameObject.Find("(Library) AnimalWorldInfoPanel").GetComponent <AnimalWorldInfoPanel>();
                if (animalInfoPanel != null)
                {
                    AddCitizenPanelControls(animalInfoPanel, out animalAssetNameLabel,
                                            out animalShowExplorerButton, new Vector3(-8.0f, 65.0f, 0.0f),
                                            out animalShowInstanceButton, new Vector3(-8.0f, 90.0f, 0.0f),
                                            out animalShowUnitButton, new Vector3(-8.0f, 115.0f, 0.0f)
                                            );
                    initializedAnimalPanel = true;
                }
            }

            if (!initializedCitizenPanel)
            {
                citizenInstancesBufferRefChain = new ReferenceChain()
                                                 .Add(CitizenManager.instance.gameObject)
                                                 .Add(CitizenManager.instance)
                                                 .Add(typeof(CitizenManager).GetField("m_instances"))
                                                 .Add(typeof(Array16 <CitizenInstance>).GetField("m_buffer"));
                citizensBufferRefChain = new ReferenceChain()
                                         .Add(CitizenManager.instance.gameObject)
                                         .Add(CitizenManager.instance)
                                         .Add(typeof(CitizenManager).GetField("m_citizens"))
                                         .Add(typeof(Array32 <Citizen>).GetField("m_buffer"));
                citizensUnitsBufferRefChain = new ReferenceChain()
                                              .Add(CitizenManager.instance.gameObject)
                                              .Add(CitizenManager.instance)
                                              .Add(typeof(CitizenManager).GetField("m_units"))
                                              .Add(typeof(Array32 <CitizenUnit>).GetField("m_buffer"));


                sceneExplorer    = FindObjectOfType <SceneExplorer>();
                citizenInfoPanel = GameObject.Find("(Library) CitizenWorldInfoPanel").GetComponent <HumanWorldInfoPanel>();
                if (citizenInfoPanel != null)
                {
                    AddCitizenPanelControls(citizenInfoPanel, out citizenAssetNameLabel,
                                            out citizenShowExplorerButton, new Vector3(-8.0f, 110.0f, 0.0f),
                                            out citizenShowInstanceButton, new Vector3(-8.0f, 135.0f, 0.0f),
                                            out citizenShowUnitButton, new Vector3(-8.0f, 160.0f, 0.0f)
                                            );
                    initializedCitizenPanel = true;
                }
            }
        }
Exemple #18
0
        public static void AddEventUI(CityServiceWorldInfoPanel cityServicePanel)
        {
            UIMultiStateButton      locationButton      = null;
            UIButton                createEventButton   = null;
            UIFastList              eventSelection      = null;
            UserEventCreationWindow eventCreationWindow = null;

            try { locationButton = cityServicePanel.Find <UIMultiStateButton>("LocationMarker"); } catch { }
            try { createEventButton = cityServicePanel.Find <UIButton>("CreateEventButton"); } catch { }
            try { eventSelection = cityServicePanel.Find <UIFastList>("EventSelectionList"); } catch { }
            try { eventCreationWindow = cityServicePanel.Find <UserEventCreationWindow>("EventCreator"); } catch { }

            FieldInfo  m_InstanceIDInfo = typeof(CityServiceWorldInfoPanel).GetField("m_InstanceID", BindingFlags.NonPublic | BindingFlags.Instance);
            InstanceID?m_InstanceID     = m_InstanceIDInfo.GetValue(cityServicePanel) as InstanceID?;

            lastInstanceID = m_InstanceID;

            BuildCreationWindow(cityServicePanel.component);

            if (eventSelection != null)
            {
                eventSelection.Hide();
            }

            if (eventCreationWindow != null)
            {
                eventCreationWindow.Hide();
            }

            if (createEventButton == null && locationButton != null)
            {
                createEventButton                  = cityServicePanel.component.AddUIComponent <UIButton>();
                createEventButton.name             = "CreateEventButton";
                createEventButton.atlas            = CimTools.CimToolsHandler.CimToolBase.SpriteUtilities.GetAtlas("Ingame");
                createEventButton.normalFgSprite   = "InfoIconLevel";
                createEventButton.disabledFgSprite = "InfoIconLevelDisabled";
                createEventButton.focusedFgSprite  = "InfoIconLevelFocused";
                createEventButton.hoveredFgSprite  = "InfoIconLevelHovered";
                createEventButton.pressedFgSprite  = "InfoIconLevelPressed";
                createEventButton.width            = locationButton.width;
                createEventButton.height           = locationButton.height;
                createEventButton.position         = locationButton.position - new Vector3(createEventButton.width - 5f, 0);
                createEventButton.eventClicked    += CreateEventButton_eventClicked;

                BuildDropdownList(createEventButton);
            }

            if (m_InstanceID != null)
            {
                BuildingManager _buildingManager = Singleton <BuildingManager> .instance;
                Building        _currentBuilding = _buildingManager.m_buildings.m_buffer[lastInstanceID.Value.Building];

                if (CityEventBuildings.instance.BuildingHasUserEvents(ref _currentBuilding))
                {
                    createEventButton.Show();
                    createEventButton.Enable();
                    m_NameField.width = originalNameWidth - 45f;
                }
                else
                {
                    if (CityEventBuildings.instance.BuildingHasEvents(ref _currentBuilding))
                    {
                        createEventButton.Show();
                        createEventButton.Disable();
                        m_NameField.width = originalNameWidth - 45f;
                    }
                    else
                    {
                        createEventButton.Hide();
                        m_NameField.width = originalNameWidth;
                    }
                }
            }
        }