예제 #1
0
        private void AddUniqueFactoriesBuildingPropertiesButton(UniqueFactoryWorldInfoPanel infoPanel,
                                                                out UIButton button,
                                                                Vector3 offset)
        {
            button = UiUtils.CreateToggleButton(infoPanel.component, offset, UIAlignAnchor.BottomLeft, (comp, e) =>
            {
                PanelType = InfoPanelType.Factory;

                InstanceID instanceID = InstanceHelper.GetInstanceID(infoPanel);

                var building = BuildingManager.instance.m_buildings.m_buffer[instanceID.Building].Info;
                try
                {
                    if (UniqueFactoryPanelWrapper == null || building != CurrentSelectedBuilding)
                    {
                        UniqueFactoryPanelWrapper = building.GenerateUniqueFactoryCustomizeItExtendedPanel();
                    }
                    else
                    {
                        UniqueFactoryPanelWrapper.isVisible = false;
                        UiUtils.DeepDestroy(UniqueFactoryPanelWrapper);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Log($"{ex.Message} - {ex.StackTrace}");
                }

                if (comp.hasFocus)
                {
                    comp.Unfocus();
                }
            });
        }
        public static void Postfix(UniqueFactoryWorldInfoPanel __instance, UIPanel ___m_productStorage)
        {
            var             m_InstanceID    = (InstanceID)typeof(WorldInfoPanel).GetField("m_InstanceID", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            var             m_productLabel  = (UILabel)typeof(UniqueFactoryWorldInfoPanel).GetField("m_productLabel", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance);
            UniqueFactoryAI uniqueFactoryAI = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)m_InstanceID.Building].Info.m_buildingAI as UniqueFactoryAI;

            m_productLabel.text = Locale.Get("WAREHOUSEPANEL_RESOURCE", uniqueFactoryAI.m_outputResource.ToString());
            if (!luxuryProductIcon)
            {
                luxuryProductIcon = ___m_productStorage.Find <UISprite>("LuxuryProductIcon");
            }
            luxuryProductIcon.spriteName = IndustryWorldInfoPanel.ResourceSpriteName(uniqueFactoryAI.m_outputResource, false);
        }
예제 #3
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;
        }