public override void OnLoad(Harmony harmony) { try { var method = typeof(Mod).GetMethodSafe(nameof(Mod.SetCrashed), false); if (method != null) { harmony.Patch(method, prefix: new HarmonyMethod(typeof( ModUpdateDatePatches), nameof(OnModCrash))); } SafeMode = false; PUtil.InitLibrary(); new PPatchManager(harmony).RegisterPatchClass(typeof(ModUpdateDatePatches)); new POptions().RegisterOptions(this, typeof(ModUpdateInfo)); new PLocalization().Register(); ModUpdateInfo.LoadSettings(); base.OnLoad(harmony); ThisMod = mod; // Shut off AVC PRegistry.PutData("PLib.VersionCheck.ModUpdaterActive", true); if (ModUpdateInfo.Settings?.AutoUpdate == true) { PRegistry.PutData("PLib.VersionCheck.PassiveSteamUpdate", true); } } catch (Exception e) { // AAAAAAAAH! PUtil.LogWarning("Mod Updater failed to load! Entering safe mode..."); PUtil.LogExcWarn(e); SafeMode = true; } }
public override void OnLoad(Harmony harmony) { base.OnLoad(harmony); PUtil.InitLibrary(); PRegistry.PutData("Bugs.FlowUtilityNetworkConduits", true); new PVersionCheck().Register(this, new SteamVersionChecker()); }
public override void OnLoad(Harmony harmony) { base.OnLoad(harmony); var options = FastTrackOptions.Instance; onWorldGenLoad.Reset(); PUtil.InitLibrary(); LocString.CreateLocStringKeys(typeof(FastTrackStrings.UI)); new PLocalization().Register(); new POptions().RegisterOptions(this, typeof(FastTrackOptions)); new PPatchManager(harmony).RegisterPatchClass(typeof(FastTrackMod)); new PVersionCheck().Register(this, new SteamVersionChecker()); // In case this goes in stock bug fix later if (options.UnstackLights) { PRegistry.PutData("Bugs.StackedLights", true); } PRegistry.PutData("Bugs.AnimFree", true); PRegistry.PutData("Bugs.MassStringsReadOnly", true); if (options.MiscOpts) { PRegistry.PutData("Bugs.ElementTagInDetailsScreen", true); } // This patch is Windows only apparently var target = typeof(Global).GetMethodSafe(nameof(Global.TestDataLocations), false); if (options.MiscOpts && target != null && typeof(Global).GetFieldSafe( nameof(Global.saveFolderTestResult), true) != null) { harmony.Patch(target, prefix: new HarmonyMethod(typeof(FastTrackMod), nameof(RemoveTestDataLocations))); #if DEBUG PUtil.LogDebug("Patched Global.TestDataLocations"); #endif } else { PUtil.LogDebug("Skipping TestDataLocations patch"); } // Another potentially Windows only patch target = typeof(Game).Assembly.GetType(nameof(InitializeCheck), false)?. GetMethodSafe(nameof(InitializeCheck.CheckForSavePathIssue), false); if (options.MiscOpts && target != null) { harmony.Patch(target, prefix: new HarmonyMethod(typeof(FastTrackMod), nameof(SkipInitCheck))); #if DEBUG PUtil.LogDebug("Patched InitializeCheck.Awake"); #endif } else { PUtil.LogDebug("Skipping InitializeCheck patch"); } GameRunning = false; }
public static void Patch(Harmony harmony) { if (!PRegistry.GetData <bool>(PATCH_KEY)) { OnRefreshUserMenuDelegate = Traverse.Create <ManualDeliveryKG>() .Field <EventSystem.IntraObjectHandler <ManualDeliveryKG> >(nameof(OnRefreshUserMenuDelegate)).Value; harmony.Patch(typeof(ManualDeliveryKG), nameof(OnSpawn), postfix: new HarmonyMethod(typeof(ManualDeliveryKGPatch), nameof(OnSpawn))); harmony.Patch(typeof(ManualDeliveryKG), nameof(OnCleanUp), prefix: new HarmonyMethod(typeof(ManualDeliveryKGPatch), nameof(OnCleanUp))); harmony.PatchTranspile(typeof(ManualDeliveryKG), "OnRefreshUserMenu", transpiler: new HarmonyMethod(typeof(ManualDeliveryKGPatch), nameof(Transpiler))); PRegistry.PutData(PATCH_KEY, true); } }
internal static void FixDiggable(Harmony instance) { const string BUG_KEY = "Bugs.DisableNeutroniumDig"; if (!StockBugFixOptions.Instance.AllowNeutroniumDig && !PRegistry.GetData <bool>( BUG_KEY)) { #if DEBUG PUtil.LogDebug("Disabling Neutronium digging"); #endif PRegistry.PutData(BUG_KEY, true); instance.Patch(typeof(Diggable).GetMethodSafe("OnSolidChanged", false, PPatchTools.AnyArguments), prefix: new HarmonyMethod( typeof(StockBugsPatches), nameof(PrefixSolidChanged))); } }
public override void OnLoad(Harmony instance) { base.OnLoad(instance); PUtil.InitLibrary(); var pm = new PPatchManager(instance); pm.RegisterPatchClass(typeof(StockBugsPatches)); pm.RegisterPatchClass(typeof(SweepFixPatches)); FixModUpdateRace(instance); PRegistry.PutData("Bugs.TepidizerPulse", true); PRegistry.PutData("Bugs.TraitExclusionSpacedOut", true); PRegistry.PutData("Bugs.TropicalPacuRooms", true); PRegistry.PutData("Bugs.AutosaveDragFix", true); new POptions().RegisterOptions(this, typeof(StockBugFixOptions)); new PVersionCheck().Register(this, new SteamVersionChecker()); }
public override void OnLoad(Harmony instance) { base.OnLoad(instance); PUtil.InitLibrary(); var pm = new PPatchManager(instance); pm.RegisterPatchClass(typeof(StockBugsPatches)); #if false pm.RegisterPatchClass(typeof(SweepFixPatches)); #endif FixModUpdateRace(instance); PRegistry.PutData("Bugs.FishReleaseCount", true); PRegistry.PutData("Bugs.TepidizerPulse", true); PRegistry.PutData("Bugs.TraitExclusionSpacedOut", true); PRegistry.PutData("Bugs.JoyReactionFix", true); new POptions().RegisterOptions(this, typeof(StockBugFixOptions)); new PVersionCheck().Register(this, new SteamVersionChecker()); }
/// <summary> /// Fixes the race condition in Steam.UpdateMods. /// </summary> /// <param name="instance">The Harmony instance to use for patching.</param> private void FixModUpdateRace(Harmony instance) { var steamMod = PPatchTools.GetTypeSafe("KMod.Steam"); const string BUG_KEY = "Bugs.ModUpdateRace"; if (steamMod != null && !PRegistry.GetData <bool>(BUG_KEY)) { // Transpile UpdateMods only for Steam versions (not EGS) #if DEBUG PUtil.LogDebug("Transpiling Steam.UpdateMods()"); #endif PRegistry.PutData(BUG_KEY, true); instance.Patch(steamMod.GetMethodSafe("UpdateMods", false, PPatchTools. AnyArguments), transpiler: new HarmonyMethod(typeof(StockBugsPatches), nameof(TranspileUpdateMods))); instance.Patch(typeof(MainMenu).GetMethodSafe("OnSpawn", false), postfix: new HarmonyMethod(typeof(StockBugsPatches), nameof(PostfixMenuSpawn))); } }
public override void OnLoad(Harmony harmony) { var method = typeof(Mod).GetMethodSafe(nameof(Mod.SetCrashed), false); if (method != null) { harmony.Patch(method, prefix: new HarmonyMethod(typeof(ModUpdateDatePatches), nameof(OnModCrash))); } PUtil.InitLibrary(); new PPatchManager(harmony).RegisterPatchClass(typeof(ModUpdateDatePatches)); new POptions().RegisterOptions(this, typeof(ModUpdateInfo)); new PLocalization().Register(); ModUpdateInfo.LoadSettings(); base.OnLoad(harmony); ThisMod = mod; // Shut off AVC PRegistry.PutData("PLib.VersionCheck.ModUpdaterActive", true); if (ModUpdateInfo.Settings?.PassiveMode == true) { PRegistry.PutData("PLib.VersionCheck.PassiveSteamUpdate", true); } }
public override void OnAllModsLoaded(Harmony harmony, IReadOnlyList <Mod> mods) { const string ASDF = "Bugs.AutosaveDragFix"; const string PACU_SAYS_NO = "Bugs.TropicalPacuRooms"; var options = FastTrackOptions.Instance; base.OnAllModsLoaded(harmony, mods); if (options.MeshRendererOptions == FastTrackOptions.MeshRendererSettings.All && mods != null) { CheckTileCompat(harmony, mods); } // Die pacu bug die if (options.AllocOpts && !PRegistry.GetData <bool>(PACU_SAYS_NO)) { GamePatches.DecorProviderRefreshFix.ApplyPatch(harmony); PRegistry.PutData(PACU_SAYS_NO, true); } if (options.FastUpdatePickups) { CheckFetchCompat(harmony); } if (!PRegistry.GetData <bool>(ASDF)) { // Fix the annoying autosave bug harmony.Patch(typeof(Timelapser), "SaveScreenshot", postfix: new HarmonyMethod( typeof(FastTrackMod), nameof(FastTrackMod.FixTimeLapseDrag))); PRegistry.PutData(ASDF, true); } if (options.FastReachability) { GamePatches.FastCellChangeMonitor.CreateInstance(); } // Fix those world strings UIPatches.FormatStringPatches.ApplyPatch(harmony); }