/// <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);
            };
        }
        void Update()
        {
            if (!initializedBuildingsPanel)
            {
                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)
                {
                    AddZonedBuildingPanelControls();
                    initializedBuildingsPanel = 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;
            }
        }
Exemple #3
0
        private ushort getSelectedBuildingID()
        {
            ZonedBuildingWorldInfoPanel panel = this.panelBuildingInfo.gameObject.
                                                GetComponent <ZonedBuildingWorldInfoPanel>();

            return(Convert.ToUInt16(
                       this.getProperty("Index", this.getField("m_InstanceID", panel))
                       .ToString()));
        }
Exemple #4
0
        /// <summary>
        /// Harmony Postfix patch to ZonedBuildingWorldInfoPanel.UpdateBindings to display visitor counts for commercial buildings.
        /// </summary>
        public static void Postfix()
        {
            // Currently selected building.
            ushort building = WorldInfoPanel.GetCurrentInstanceID().Building;

            // Create visit label if it isn't already set up.
            if (visitLabel == null)
            {
                // Get info panel.
                ZonedBuildingWorldInfoPanel infoPanel = UIView.library.Get <ZonedBuildingWorldInfoPanel>(typeof(ZonedBuildingWorldInfoPanel).Name);

                // Add current visitor count label.
                visitLabel           = UIControls.AddLabel(infoPanel.component, 65f, 280f, Translations.Translate("RPR_INF_VIS"), textScale: 0.75f);
                visitLabel.textColor = new Color32(185, 221, 254, 255);
                visitLabel.font      = Resources.FindObjectsOfTypeAll <UIFont>().FirstOrDefault((UIFont f) => f.name == "OpenSans-Regular");

                // Position under existing Highly Educated workers count row in line with total workplace count label.
                UIComponent situationLabel = infoPanel.Find("WorkSituation");
                UIComponent workerLabel    = infoPanel.Find("HighlyEducatedWorkers");
                if (situationLabel != null && workerLabel != null)
                {
                    visitLabel.absolutePosition = new Vector2(situationLabel.absolutePosition.x, workerLabel.absolutePosition.y + 25f);
                }
                else
                {
                    Logging.Error("couldn't find ZonedBuildingWorldInfoPanel components");
                }
            }

            // Local references.
            Building[]   buildingBuffer = Singleton <BuildingManager> .instance.m_buildings.m_buffer;
            BuildingInfo buildingInfo   = buildingBuffer[building].Info;

            // Is this a commercial building?
            CommercialBuildingAI commercialAI = buildingInfo.GetAI() as CommercialBuildingAI;

            if (commercialAI == null)
            {
                // Not a commercial building - hide the label.
                visitLabel.Hide();
            }
            else
            {
                // Commercial building - show the label.
                visitLabel.Show();

                // Get current visitor count.
                int aliveCount = 0, totalCount = 0;
                Citizen.BehaviourData behaviour = new Citizen.BehaviourData();
                GetVisitBehaviour(commercialAI, building, ref buildingBuffer[building], ref behaviour, ref aliveCount, ref totalCount);

                // Display visitor count.
                visitLabel.text = totalCount.ToString() + " / " + commercialAI.CalculateVisitplaceCount((ItemClass.Level)buildingBuffer[building].m_level, new ColossalFramework.Math.Randomizer(building), buildingBuffer[building].Width, buildingBuffer[building].Length).ToString() + " " + Translations.Translate("RPR_INF_VIS");
            }
        }
        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 GetMaxLevels()
 {
     int maxCommercialHigh  = ZonedBuildingWorldInfoPanel.GetMaxLevel(ItemClass.Zone.CommercialHigh);
     int maxCommercialLow   = ZonedBuildingWorldInfoPanel.GetMaxLevel(ItemClass.Zone.CommercialLow);
     int maxDistant         = ZonedBuildingWorldInfoPanel.GetMaxLevel(ItemClass.Zone.Distant);
     int maxIndustrial      = ZonedBuildingWorldInfoPanel.GetMaxLevel(ItemClass.Zone.Industrial);
     int maxNone            = ZonedBuildingWorldInfoPanel.GetMaxLevel(ItemClass.Zone.None);
     int maxOffice          = ZonedBuildingWorldInfoPanel.GetMaxLevel(ItemClass.Zone.Office);
     int maxResidentialHigh = ZonedBuildingWorldInfoPanel.GetMaxLevel(ItemClass.Zone.ResidentialHigh);
     int maxResidentialLow  = ZonedBuildingWorldInfoPanel.GetMaxLevel(ItemClass.Zone.ResidentialLow);
     int maxUnzoned         = ZonedBuildingWorldInfoPanel.GetMaxLevel(ItemClass.Zone.Unzoned);
 }
        public override void OnLevelLoaded(LoadMode mode)
        {
            if (_HistoricalStatusCheckBox != null)
            {
                return;
            }

            ZonedBuildingWorldInfoPanel panel = UIView.library.Get <ZonedBuildingWorldInfoPanel>(typeof(ZonedBuildingWorldInfoPanel).Name);
            UICheckBox checkBox = panel.component.AddUIComponent <UICheckBox>();

            checkBox.width        = panel.component.width;
            checkBox.height       = 20f;
            checkBox.clipChildren = true;

            UISprite sprite = checkBox.AddUIComponent <UISprite>();

            sprite.spriteName       = "ToggleBase";
            sprite.size             = new Vector2(16f, 16f);
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).spriteName = "ToggleBaseFocused";
            checkBox.checkedBoxObject.size             = new Vector2(16f, 16f);
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            checkBox.label                  = checkBox.AddUIComponent <UILabel>();
            checkBox.label.text             = " ";
            checkBox.label.textScale        = 0.9f;
            checkBox.label.relativePosition = new Vector3(22f, 2f);

            checkBox.name = "HistoricalStatus";
            checkBox.text = "Historical Status";

            checkBox.relativePosition = new Vector3(14f, 164f + 130f + 5f);

            panel.component.height = 321f + 5f + 16f;

            _HistoricalStatusCheckBox = checkBox;

            checkBox.eventCheckChanged += (component, check) =>
            {
                ushort buildingId = WorldInfoPanel.GetCurrentInstanceID().Building;

                if (check)
                {
                    HistoricalStatusDataManager.Instance.AddBuildingId(buildingId);
                }
                else
                {
                    HistoricalStatusDataManager.Instance.RemoveBuildingId(buildingId);
                }
            };
        }
        private void Update()
        {
            try
            {
                if (ModConfig.Instance.ConfigUpdated)
                {
                    if (_extenderPanel != null)
                    {
                        _extenderPanel.parent.isVisible = false;
                        UnityEngine.Object.Destroy(_extenderPanel.gameObject);
                    }

                    _initialized = false;

                    ModConfig.Instance.ConfigUpdated = false;
                }

                if (!_initialized)
                {
                    _zonedBuildingWorldInfoPanel = GameObject.Find("(Library) ZonedBuildingWorldInfoPanel").GetComponent <ZonedBuildingWorldInfoPanel>();

                    if (_zonedBuildingWorldInfoPanel == null)
                    {
                        return;
                    }

                    _effectsOnZonedBuilding    = new Dictionary <int, float>();
                    _maxEffectsOnZonedBuilding = new Dictionary <int, float>();
                    _effectChartHover          = new UISprite();
                    _effectCharts   = new Dictionary <int, UIRadialChart>();
                    _effectOverlays = new Dictionary <int, UILabel>();
                    _effectLegends  = new Dictionary <int, UILabel>();
                    _effectIcons    = new Dictionary <int, UISprite>();

                    CreateExtenderPanel();

                    _initialized = true;
                }

                if (!_zonedBuildingWorldInfoPanel.component.isVisible)
                {
                    _cachedBuildingID = 0;
                    return;
                }

                UpdateBindings();
            }
            catch (Exception e)
            {
                Debug.Log("[Show It!] ZonedBuildingExtenderPanel:Update -> Exception: " + e.Message);
            }
        }
Exemple #10
0
        private bool FindComponents()
        {
            if (_panel != null && _HistoricalStatusCheckBox != null)
            {
                return(true);
            }

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

            _HistoricalStatusCheckBox = _panel.component.Find <UICheckBox>("HistoricalStatus");
            return(_HistoricalStatusCheckBox != null);
        }
Exemple #11
0
//        private UIButton _zonedBuildingLevelUpButton2;
//        private UIButton _buildingSetOnFireButton2;

        private void Update()
        {
            if (!_initialized)
            {
                _zonedBuildingInfoPanel      = GameObject.Find("(Library) ZonedBuildingWorldInfoPanel").GetComponent <ZonedBuildingWorldInfoPanel>();
                _zonedBuildingLevelUpButton1 = UIUtil.CreateLevelUpButton(_zonedBuildingInfoPanel.component, BuildingLevelUpHandler);
                _buildingSetOnFireButton1    = UIUtil.CreateSetOnFireButton(_zonedBuildingInfoPanel.component, BuildingSetOnFireHandler);
//                _cityServiceInfoPanel = GameObject.Find("(Library) CityServiceWorldInfoPanel").GetComponent<CityServiceWorldInfoPanel>();
//                _zonedBuildingLevelUpButton2 = UIUtil.CreateLevelUpButton(_cityServiceInfoPanel.component, BuildingLevelUpHandler);
//                _buildingSetOnFireButton2 = UIUtil.CreateSetOnFireButton(_cityServiceInfoPanel.component, BuildingSetOnFireHandler);
                _districtWorldInfoPanel = GameObject.Find("(Library) DistrictWorldInfoPanel").GetComponent <DistrictWorldInfoPanel>();
                UIUtil.CreateLevelUpButton(_districtWorldInfoPanel.component, DistrictLevelUpHandler);
                UIUtil.CreateSetOnFireButton(_districtWorldInfoPanel.component, DistrictSetOnFireHandler);
                _initialized = true;
            }
            if (!_zonedBuildingInfoPanel.component.isVisible)
            {
                return;
            }
            SetZonedBuildingButtonsVisibility();
//            SetServiceBuildingButtonsVisibility();
        }
        /// <summary>
        /// Adds button to access building details from building info panels.
        /// </summary>
        internal static void AddInfoPanelButton()
        {
            // Get parent panel and apply button.
            ZonedBuildingWorldInfoPanel infoPanel = UIView.library.Get <ZonedBuildingWorldInfoPanel>(typeof(ZonedBuildingWorldInfoPanel).Name);
            UIButton panelButton = UIUtils.CreateButton(infoPanel.component, 133);

            // Basic setup.
            panelButton.height                = 19.5f;
            panelButton.textScale             = 0.65f;
            panelButton.textVerticalAlignment = UIVerticalAlignment.Bottom;
            panelButton.relativePosition      = new UnityEngine.Vector3(infoPanel.component.width - panelButton.width - 10, 120);
            panelButton.text = Translations.Translate("RPR_REALPOP");

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

            // Event handler.
            panelButton.eventClick += (control, clickEvent) =>
            {
                // Select current building in the building details panel and show.
                BuildingDetailsPanel.Open(InstanceManager.GetPrefabInfo(WorldInfoPanel.GetCurrentInstanceID()) as BuildingInfo);
            };
        }
Exemple #13
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;
        }
Exemple #14
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 #15
0
 static void Postfix(ZonedBuildingWorldInfoPanel __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.Zoned].selectedColor = Painter.instance.GetColor();
 }
        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;
                }
            }
        }
        void Update()
        {
            if (!initializedBuildingsPanel)
            {
                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)
                {
                    AddZonedBuildingPanelControls();
                    initializedBuildingsPanel = 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;
            }
        }