public new virtual void InitializePrefab()
 {
     try
     {
         PreInitializeHook(this);
     }
     catch
     {
         isGrowable     = false;
         previousPrefab = null;
     }
     RedirectionHelper.RevertRedirect(_InitializePrefab_original, _InitializePrefab_state);
     try
     {
         base.InitializePrefab();
     }
     finally
     {
         RedirectionHelper.RedirectCalls(_InitializePrefab_original, _InitializePrefab_detour);
     }
     try
     {
         PostInitializeHook(this);
     }
     catch (Exception e)
     {
         UnityEngine.Debug.LogException(e);
     }
 }
        public static void Revert()
        {
            if (deployed)
            {
                if (Util.IsModActive("Prefab Hook"))
                {
                    var type = Util.FindType("BuildingInfoHookReflective");
                    if (type == null)
                    {
                        UnityEngine.Debug.LogError(
                            "Building Themes - type 'BuildingInfoHookReflective' not found. Update Prefab Hook!");
                    }
                    else
                    {
                        type.GetMethod("Revert", BindingFlags.Public | BindingFlags.Static)
                        .Invoke(null, new object[]
                        {
                        });
                    }
                }
                else
                {
                    RedirectionHelper.RevertRedirect(_InitializePrefab_original, _InitializePrefab_state);
                    _InitializePrefab_original = null;
                    _InitializePrefab_detour   = null;
                }
                deployed = false;

                Debugger.Log("Better Themes: BuildingInfo Methods restored!");
            }
        }
Пример #3
0
        // Detours

        public void SetParentButton(UIButton button)
        {
            if (button == null)
            {
                return;
            }

            // We have to remove the custom tab before the original SetParentButton method is called
            // SetParentButton() is searching for a TutorialUITag component which our tab does not have
            GUI.ThemePolicyTab.RemoveThemesTab();

            // Call the original method
            RedirectionHelper.RevertRedirect(_PoliciesPanel_SetParentButton_original, _PoliciesPanel_SetParentButton_state);
            try
            {
                _PoliciesPanel_SetParentButton_original.Invoke(this, new object[] { button });
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                // ignore this error, seems harmless
            }
            RedirectionHelper.RedirectCalls(_PoliciesPanel_SetParentButton_original, _PoliciesPanel_SetParentButton_detour);

            // After the method call, add our custom tab again
            GUI.ThemePolicyTab.AddThemesTab();
        }
        public static void Revert()
        {
            if (deployed)
            {
                RedirectionHelper.RevertRedirect(_BuildingManager_GetRandomBuildingInfo_original, _BuildingManager_GetRandomBuildingInfo_state);
                _BuildingManager_GetRandomBuildingInfo_original = null;
                _BuildingManager_GetRandomBuildingInfo_detour   = null;

                deployed = false;

                Debugger.Log("Building Themes: BuildingManager Methods restored!");
            }
        }
Пример #5
0
        public static void Revert()
        {
            if (deployed)
            {
                RedirectionHelper.RevertRedirect(_original, _state);
                _original = null;
                _detour   = null;

                deployed = false;

                Debugger.Log("Building Themes: DistrictWorldInfoPanel Methods restored!");
            }
        }
Пример #6
0
        public static void Revert()
        {
            if (deployed)
            {
                RedirectionHelper.RevertRedirect(_GetUpgradeInfo_original, _GetUpgradeInfo_state);
                _GetUpgradeInfo_original = null;
                _GetUpgradeInfo_detour   = null;

                deployed = false;

                Debugger.LogFormat("Building Themes: {0} Methods restored!", typeof(A).Name);
            }
        }
Пример #7
0
        public static void Revert()
        {
            if (deployed)
            {
                RedirectionHelper.RevertRedirect(_InitializePrefab_original, _InitializePrefab_state);
                _InitializePrefab_original = null;
                _InitializePrefab_detour   = null;

                deployed = false;

                Debugger.Log("Better Themes: BuildingInfo Methods restored!");
            }
        }
Пример #8
0
        public static void Revert()
        {
            if (deployed)
            {
                RedirectionHelper.RevertRedirect(_ImmaterialResourceManager_AddResource_original, _ImmaterialResourceManager_AddResource_state);
                _ImmaterialResourceManager_AddResource_original = null;
                _ImmaterialResourceManager_AddResource_detour   = null;

                deployed = false;

                Debugger.Log("Building Themes: ImmaterialResourceManager Methods restored!");
            }
        }
Пример #9
0
        public static void Revert()
        {
            if (deployed)
            {
                RedirectionHelper.RevertRedirect(_DistrictManager_ReleaseDistrictImplementation_original, _DistrictManager_ReleaseDistrictImplementation_state);
                _DistrictManager_ReleaseDistrictImplementation_original = null;
                _DistrictManager_ReleaseDistrictImplementation_detour = null;

                deployed = false;

                Debugger.Log("Building Themes: DistrictManager Methods restored!");
            }
        }
Пример #10
0
        // Detours

        public void SetParentButton(UIButton button)
        {
            // We have to remove the custom tab before the original SetParentButton method is called
            // SetParentButton() is searching for a TutorialUITag component which our tab does not have
            GUI.ThemePolicyTab.RemoveThemesTab();

            // Call the original method
            RedirectionHelper.RevertRedirect(_PoliciesPanel_SetParentButton_original, _PoliciesPanel_SetParentButton_state);
            _PoliciesPanel_SetParentButton_original.Invoke(this, new object[] { button });
            RedirectionHelper.RedirectCalls(_PoliciesPanel_SetParentButton_original, _PoliciesPanel_SetParentButton_detour);

            // After the method call, add our custom tab again
            GUI.ThemePolicyTab.AddThemesTab();
        }
Пример #11
0
        private void RefreshPanel()
        {
            // We have to remove the custom tab before the original RefreshPanel method is called
            // RefreshPanel() checks for every policy button if the assigned policy is loaded
            // Our fake policy buttons are not related to a game policy
            GUI.ThemePolicyTab.RemoveThemesTab();

            // Call the original method
            RedirectionHelper.RevertRedirect(_PoliciesPanel_RefreshPanel_original, _PoliciesPanel_RefreshPanel_state);
            _PoliciesPanel_RefreshPanel_original.Invoke(this, new object[] { });
            RedirectionHelper.RedirectCalls(_PoliciesPanel_RefreshPanel_original, _PoliciesPanel_RefreshPanel_detour);

            // After the method call, add our custom tab again
            GUI.ThemePolicyTab.AddThemesTab();
        }
Пример #12
0
        public static void Revert()
        {
            if (deployed)
            {
                RedirectionHelper.RevertRedirect(_ZoneBlock_SimulationStep_original, _ZoneBlock_SimulationStep_state);
                _ZoneBlock_SimulationStep_original = null;
                _ZoneBlock_SimulationStep_detour   = null;

                _CheckBlock  = null;
                _IsGoodPlace = null;

                deployed = false;

                Debugger.Log("Building Themes: ZoneBlock Methods restored!");
            }
        }
Пример #13
0
        public static void Revert()
        {
            if (deployed)
            {
                RedirectionHelper.RevertRedirect(_PoliciesPanel_RefreshPanel_original, _PoliciesPanel_RefreshPanel_state);
                _PoliciesPanel_RefreshPanel_original = null;
                _PoliciesPanel_RefreshPanel_detour   = null;

                RedirectionHelper.RevertRedirect(_PoliciesPanel_SetParentButton_original, _PoliciesPanel_SetParentButton_state);
                _PoliciesPanel_SetParentButton_original = null;
                _PoliciesPanel_SetParentButton_detour   = null;

                deployed = false;

                Debugger.Log("Building Themes: PoliciesPanel Methods restored!");
            }
        }
Пример #14
0
        // Detours

        public int AddResource(ImmaterialResourceManager.Resource resource, int rate, Vector3 positionArg, float radius)
        {
            if (Debugger.Enabled && debugCounter < 10)
            {
                debugCounter++;
                Debugger.Log("Building Themes: Detoured ImmaterialResource.AddResource was called.");
            }

            // Catch the position of the abandoned building
            if (resource == ImmaterialResourceManager.Resource.Abandonment)
            {
                BuildingThemesMod.position = positionArg;
            }

            // Call the original method
            RedirectionHelper.RevertRedirect(_ImmaterialResourceManager_AddResource_original, _ImmaterialResourceManager_AddResource_state);
            var result = Singleton <ImmaterialResourceManager> .instance.AddResource(resource, rate, positionArg, radius);

            RedirectionHelper.RedirectCalls(_ImmaterialResourceManager_AddResource_original, _ImmaterialResourceManager_AddResource_detour);

            return(result);
        }
Пример #15
0
        public new virtual void InitializePrefab()
        {
            bool growable = this.m_class.GetZone() != ItemClass.Zone.None;

            if (growable)
            {
                //Debugger.Log("InitializePrefab called: " + this.name);
            }

            RedirectionHelper.RevertRedirect(_InitializePrefab_original, _InitializePrefab_state);
            base.InitializePrefab();
            RedirectionHelper.RedirectCalls(_InitializePrefab_original, _InitializePrefab_detour);

            if (growable)
            {
                var prefabVariations = Singleton <BuildingVariationManager> .instance.CreateVariations(this).Values.ToArray <BuildingInfo>();

                if (prefabVariations.Length > 0)
                {
                    PrefabCollection <BuildingInfo> .InitializePrefabs("BetterUpgrade", prefabVariations, null);
                }
                //Debugger.Log("InitializePrefab done:   " + this.name);
            }
        }