Пример #1
0
 public static void OnLoad()
 {
     PUtil.InitLibrary();
     PLocalization.Register();
     FilteredGasPumpConfig.RegisterBuilding();
     FilteredLiquidPumpConfig.RegisterBuilding();
     VacuumPumpConfig.RegisterBuilding();
     PUtil.RegisterPatchClass(typeof(FilteredPump));
 }
Пример #2
0
 public static void OnLoad()
 {
     PUtil.InitLibrary();
     POptions.RegisterOptions(typeof(FastSaveOptions));
     CleanUsageLogs.RegisterPostload();
     // Sorry, Fast Save now requires a restart to take effect because of background!
     PUtil.LogDebug("FastSave in mode: {0}".F(FastSaveOptions.Instance.Mode));
     PLocalization.Register();
 }
Пример #3
0
 public static void OnLoad()
 {
     bicCompat        = null;
     buildingInstance = new BuildThermalTooltip();
     PUtil.InitLibrary();
     POptions.RegisterOptions(typeof(ThermalTooltipsOptions));
     PLocalization.Register();
     TooltipInstance = null;
     PUtil.RegisterPatchClass(typeof(ThermalTooltipsPatches));
 }
Пример #4
0
 public static void OnLoad()
 {
     PUtil.InitLibrary();
     PLocalization.Register();
     LocString.CreateLocStringKeys(typeof(ToastControlStrings.UI));
     POptions.RegisterOptions(typeof(ToastControlOptions));
     PUtil.RegisterPatchClass(typeof(ToastControlPopups));
     ToastControlPopups.ReloadOptions();
     // No default key bind
     inGameSettings = PAction.Register(ToastControlStrings.ACTION_KEY,
                                       ToastControlStrings.ACTION_TITLE);
 }
Пример #5
0
        public static void OnLoad()
        {
            PUtil.InitLibrary();
            to11 = new Temperature();
            var tr11 = Traverse.Create(to11);

            tr11.SetProperty("min", 80.0f);
            tr11.SetProperty("max", 110.0f);
            PLocalization.Register();
            POptions.RegisterOptions(typeof(Challenge100KOptions));
            PUtil.RegisterPatchClass(typeof(Challenge100K));
        }
Пример #6
0
        public static void OnLoad(string path)
        {
            PUtil.InitLibrary(true);
            PLocalization.Register();
            POptions.RegisterOptions(typeof(SandboxConduitToolSettings));

            ReadOptions();

            PKeyBinding pKeyBinding = null;

            if (KKeyCodeUtil.TryParse(SandboxConduitToolSettings.Instance.Hotkey, out KKeyCode keyCode, out Modifier modifier))
            {
                pKeyBinding = new PKeyBinding(keyCode, modifier);
            }
            PAction = PAction.Register("SandboxConduitToolAction", "Sandbox Conduit Tool", pKeyBinding);
        }
Пример #7
0
 public static void OnLoad()
 {
     FinishBlock                     = null;
     FinishColor                     = ScriptableObject.CreateInstance <ColorStyleSetting>();
     FinishColor.activeColor         = new Color(0.6f, 1.0f, 0.6f, 1.0f);
     FinishColor.inactiveColor       = new Color(0.286f, 1.0f, 0.286f, 1.0f);
     FinishColor.disabledColor       = new Color(0.4f, 0.416f, 0.4f, 1.0f);
     FinishColor.disabledActiveColor = new Color(0.588f, 0.625f, 0.588f, 1.0f);
     FinishColor.hoverColor          = new Color(0.6f, 1.0f, 0.6f, 1.0f);
     FinishColor.disabledhoverColor  = new Color(0.46f, 0.5f, 0.46f, 1.0f);
     FinishTask = null;
     Work       = null;
     PUtil.InitLibrary();
     LocString.CreateLocStringKeys(typeof(FinishTasksStrings.DUPLICANTS));
     LocString.CreateLocStringKeys(typeof(FinishTasksStrings.UI));
     PLocalization.Register();
 }
Пример #8
0
        public static void OnLoad(string path)
        {
            var inst = ModDebugRegistry.Instance;

            RunningPLibAssembly = typeof(PUtil).Assembly;
            PUtil.InitLibrary();
            if (DebugNotIncludedOptions.Instance?.DetailedBacktrace ?? true)
            {
                DebugLogger.InstallExceptionLogger();
            }
            POptions.RegisterOptions(typeof(DebugNotIncludedOptions));
            // Set up strings
            LocString.CreateLocStringKeys(typeof(DebugNotIncludedStrings.UI));
            LocString.CreateLocStringKeys(typeof(DebugNotIncludedStrings.INPUT_BINDINGS));
            PLocalization.Register();
            if (DebugNotIncludedOptions.Instance?.LogAsserts ?? true)
            {
                LogAllFailedAsserts();
            }
            foreach (var mod in Global.Instance.modManager?.mods)
            {
                if (mod.GetModBasePath() == path)
                {
                    ThisMod = mod;
                    break;
                }
            }
            if (ThisMod == null)
            {
                DebugLogger.LogWarning("Unable to determine KMod instance!");
            }
            else
            {
                inst.RegisterModAssembly(Assembly.GetExecutingAssembly(), inst.GetDebugInfo(
                                             ThisMod));
            }
            // Default UI debug key is ALT+U
            UIDebugAction = PAction.Register("DebugNotIncluded.UIDebugAction",
                                             DebugNotIncludedStrings.INPUT_BINDINGS.DEBUG.SNAPSHOT, new PKeyBinding(
                                                 KKeyCode.U, Modifier.Alt));
            // Must postload the mods dialog to come out after aki's mods, ony's mods, PLib
            // options, and so forth
            PUtil.RegisterPatchClass(typeof(DebugNotIncludedPatches));
        }
Пример #9
0
        public static void OnLoad(string path)
        {
            PUtil.InitLibrary();
            POptions.RegisterOptions(typeof(ModUpdateInfo));
            PLocalization.Register();
            // Try to read the backup config first
            string backupPath = ExtensionMethods.BackupConfigPath;

            if (File.Exists(backupPath))
            {
                try {
                    // Copy and overwrite our config if possible
                    File.Copy(backupPath, ExtensionMethods.ConfigPath, true);
                    File.Delete(backupPath);
                    PUtil.LogDebug("Restored configuration settings after self-update");
                } catch (IOException) {
                    PUtil.LogWarning("Unable to restore configuration for Mod Updater");
                }
            }
Пример #10
0
 public static void OnLoad()
 {
     PUtil.InitLibrary();
     PLocalization.Register();
     PUtil.RegisterPatchClass(typeof(FoodTooltipPatches));
 }
Пример #11
0
        /// <summary>
        /// Applies all patches.
        /// </summary>
        /// <param name="instance">The Harmony instance to use when patching.</param>
        private static void PatchAll(HarmonyInstance instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            // ColonyAchievementStatus
            instance.Patch(typeof(ColonyAchievementStatus), "Serialize",
                           PatchMethod(nameof(Serialize_Prefix)), null);

            // GameInputMapping
            instance.Patch(typeof(GameInputMapping), "SetDefaultKeyBindings", null,
                           PatchMethod(nameof(SetDefaultKeyBindings_Postfix)));

            // KInputController
            instance.PatchConstructor(typeof(KInputController.KeyDef), new Type[] {
                typeof(KKeyCode), typeof(Modifier)
            }, null, PatchMethod(nameof(CKeyDef_Postfix)));
            instance.Patch(typeof(KInputController), "IsActive",
                           PatchMethod(nameof(IsActive_Prefix)), null);
            instance.Patch(typeof(KInputController), "QueueButtonEvent",
                           PatchMethod(nameof(QueueButtonEvent_Prefix)), null);

            if (PLightManager.InitInstance())
            {
                // DiscreteShadowCaster
                instance.Patch(typeof(DiscreteShadowCaster), "GetVisibleCells",
                               PatchMethod(nameof(GetVisibleCells_Prefix)), null);

                // Light2D
                instance.Patch(typeof(Light2D), "AddToScenePartitioner",
                               PatchMethod(nameof(AddToScenePartitioner_Prefix)), null);
                instance.Patch(typeof(Light2D), "RefreshShapeAndPosition", null,
                               PatchMethod(nameof(RefreshShapeAndPosition_Postfix)));

                // LightGridEmitter
                instance.Patch(typeof(LightGridEmitter), "AddToGrid", null,
                               PatchMethod(nameof(AddToGrid_Postfix)));
                instance.Patch(typeof(LightGridEmitter), "ComputeLux",
                               PatchMethod(nameof(ComputeLux_Prefix)), null);
                instance.Patch(typeof(LightGridEmitter), "RemoveFromGrid",
                               null, PatchMethod(nameof(RemoveFromGrid_Postfix)));
                instance.Patch(typeof(LightGridEmitter), "UpdateLitCells",
                               PatchMethod(nameof(UpdateLitCells_Prefix)), null);

                // LightGridManager
                instance.Patch(typeof(LightGridManager), "CreatePreview",
                               PatchMethod(nameof(CreatePreview_Prefix)), null);

                // LightShapePreview
                instance.Patch(typeof(LightShapePreview), "Update",
                               PatchMethod(nameof(LightShapePreview_Update_Prefix)), null);

                // Rotatable
                instance.Patch(typeof(Rotatable), "OrientVisualizer", null,
                               PatchMethod(nameof(OrientVisualizer_Postfix)));
            }

            // PBuilding
            instance.Patch(typeof(BuildingTemplates), "CreateBuildingDef", null,
                           PatchMethod(nameof(CreateBuildingDef_Postfix)));
            instance.Patch(typeof(EquipmentTemplates), "CreateEquipmentDef", null,
                           PatchMethod(nameof(CreateEquipmentDef_Postfix)));
            if (PBuilding.CheckBuildings())
            {
                instance.Patch(typeof(Db), "Initialize",
                               PatchMethod(nameof(Initialize_Prefix)), null);
                instance.Patch(typeof(GeneratedBuildings), "LoadGeneratedBuildings",
                               PatchMethod(nameof(LoadGeneratedBuildings_Prefix)), null);
            }

            // PCodex
            instance.Patch(typeof(CodexCache), "CollectEntries", null,
                           PatchMethod(nameof(CollectEntries_Postfix)));
            instance.Patch(typeof(CodexCache), "CollectSubEntries", null,
                           PatchMethod(nameof(CollectSubEntries_Postfix)));

            // PLocalization
            var locale = Localization.GetLocale();

            if (locale != null)
            {
                PLocalization.LocalizeAll(locale);
            }

            // ModsScreen
            POptions.Init();
            instance.Patch(typeof(ModsScreen), "BuildDisplay", null,
                           PatchMethod(nameof(BuildDisplay_Postfix)));

            // SteamUGCService
            try {
                instance.PatchTranspile(typeof(SteamUGCService), "LoadPreviewImage",
                                        PatchMethod(nameof(LoadPreviewImage_Transpile)));
            } catch (TypeLoadException) {
                // Not a Steam install, ignoring
            }

            // Postload
            PUtil.ExecutePostload();
        }
Пример #12
0
 public DebugNotIncludedPatches()
 {
     loc = new PLocalization();
 }
Пример #13
0
 public static void OnLoad()
 {
     PUtil.InitLibrary();
     POptions.RegisterOptions(typeof(ClaustrophobiaOptions));
     PLocalization.Register();
 }
Пример #14
0
 public static void OnLoad()
 {
     PUtil.InitLibrary();
     PLocalization.Register();
     VLib.Register();
 }
Пример #15
0
		public static void OnLoad() {
			PUtil.InitLibrary();
			POptions.RegisterOptions(typeof(SweepByTypeOptions));
			PLocalization.Register();
			Options = null;
		}
Пример #16
0
        /// <summary>
        /// Applies all patches.
        /// </summary>
        /// <param name="instance">The Harmony instance to use when patching.</param>
        private static void PatchAll(HarmonyInstance instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            // ColonyAchievementStatus
            instance.Patch(typeof(ColonyAchievementStatus), "Serialize",
                           PatchMethod(nameof(Serialize_Prefix)), null);

            // Db
            instance.Patch(typeof(Db), "Initialize", PatchMethod(nameof(Initialize_Prefix)),
                           PatchMethod(nameof(Initialize_Postfix)));

            // Game
            instance.Patch(typeof(Game), "DestroyInstances", null, PatchMethod(nameof(
                                                                                   Game_DestroyInstances_Postfix)));
            instance.Patch(typeof(Game), "OnPrefabInit", null, PatchMethod(nameof(
                                                                               Game_OnPrefabInit_Postfix)));

            // GameInputMapping
            instance.Patch(typeof(GameInputMapping), "SetDefaultKeyBindings", null,
                           PatchMethod(nameof(SetDefaultKeyBindings_Postfix)));

            // GameUtil
            instance.Patch(typeof(GameUtil), "GetKeycodeLocalized",
                           PatchMethod(nameof(GetKeycodeLocalized_Prefix)), null);

            // KInputController
            instance.PatchConstructor(typeof(KInputController.KeyDef), new Type[] {
                typeof(KKeyCode), typeof(Modifier)
            }, null, PatchMethod(nameof(CKeyDef_Postfix)));
            instance.Patch(typeof(KInputController), "IsActive",
                           PatchMethod(nameof(IsActive_Prefix)), null);
            instance.Patch(typeof(KInputController), "QueueButtonEvent",
                           PatchMethod(nameof(QueueButtonEvent_Prefix)), null);

            if (PLightManager.InitInstance())
            {
                // DiscreteShadowCaster
                instance.Patch(typeof(DiscreteShadowCaster), "GetVisibleCells",
                               PatchMethod(nameof(GetVisibleCells_Prefix)), null);

                // Light2D
                instance.Patch(typeof(Light2D), "AddToScenePartitioner",
                               PatchMethod(nameof(AddToScenePartitioner_Prefix)), null);
                instance.Patch(typeof(Light2D), "RefreshShapeAndPosition", null,
                               PatchMethod(nameof(RefreshShapeAndPosition_Postfix)));

                // LightGridEmitter
                instance.Patch(typeof(LightGridEmitter), "AddToGrid", null,
                               PatchMethod(nameof(AddToGrid_Postfix)));
                instance.Patch(typeof(LightGridEmitter), "ComputeLux",
                               PatchMethod(nameof(ComputeLux_Prefix)), null);
                instance.Patch(typeof(LightGridEmitter), "RemoveFromGrid",
                               null, PatchMethod(nameof(RemoveFromGrid_Postfix)));
                instance.Patch(typeof(LightGridEmitter), "UpdateLitCells",
                               PatchMethod(nameof(UpdateLitCells_Prefix)), null);

                // LightGridManager
                instance.Patch(typeof(LightGridManager), "CreatePreview",
                               PatchMethod(nameof(CreatePreview_Prefix)), null);

                // LightShapePreview
                instance.Patch(typeof(LightShapePreview), "Update",
                               PatchMethod(nameof(LightShapePreview_Update_Prefix)), null);

                // Rotatable
                instance.Patch(typeof(Rotatable), "OrientVisualizer", null,
                               PatchMethod(nameof(OrientVisualizer_Postfix)));
            }

            // MainMenu
            instance.Patch(typeof(MainMenu), "OnSpawn", null, PatchMethod(
                               nameof(MainMenu_OnSpawn_Postfix)));

            // PBuilding
            instance.Patch(typeof(BuildingTemplates), "CreateBuildingDef", null,
                           PatchMethod(nameof(CreateBuildingDef_Postfix)));
            instance.Patch(typeof(EquipmentTemplates), "CreateEquipmentDef", null,
                           PatchMethod(nameof(CreateEquipmentDef_Postfix)));
            if (PBuilding.CheckBuildings())
            {
                instance.Patch(typeof(GeneratedBuildings), "LoadGeneratedBuildings",
                               PatchMethod(nameof(LoadGeneratedBuildings_Prefix)), null);
            }

            // PCodex
            instance.Patch(typeof(CodexCache), "CollectEntries", null,
                           PatchMethod(nameof(CollectEntries_Postfix)));
            instance.Patch(typeof(CodexCache), "CollectSubEntries", null,
                           PatchMethod(nameof(CollectSubEntries_Postfix)));

            // PLocalization
            var locale = Localization.GetLocale();

            if (locale != null)
            {
                PLocalization.LocalizeAll(locale);
            }

            // ModsScreen
            POptions.Init();
            instance.Patch(typeof(ModsScreen), "BuildDisplay", null,
                           PatchMethod(nameof(BuildDisplay_Postfix)));

            // SteamUGCService
            var ugc = PPatchTools.GetTypeSafe("SteamUGCService", "Assembly-CSharp");

            if (ugc != null)
            {
                try {
                    instance.PatchTranspile(ugc, "LoadPreviewImage", PatchMethod(nameof(
                                                                                     LoadPreviewImage_Transpile)));
                } catch (Exception e) {
                    PUtil.LogExcWarn(e);
                }
            }

            // TMPro.TMP_InputField
            try {
                instance.Patch(typeof(TMPro.TMP_InputField), "OnEnable", null,
                               PatchMethod(nameof(OnEnable_Postfix)));
            } catch (Exception) {
                PUtil.LogWarning("Unable to patch TextMeshPro bug, text fields may display " +
                                 "improperly inside scroll areas");
            }

            // Postload, legacy and normal
            PPatchManager.ExecuteLegacyPostload();
            PPatchManager.RunAll(RunAt.AfterModsLoad);
        }
Пример #17
0
 public static void OnLoad()
 {
     PUtil.InitLibrary();
     PLocalization.Register();
     RegisterBuilding();
 }
Пример #18
0
 public static void OnLoad()
 {
     Z.net = new Network();
     PUtil.InitLibrary(true);
     PLocalization.Register();
 }