From ef5c971c5a1bcaa4991523d793d1447cef3ec77a Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Sat, 23 Sep 2023 03:26:59 +0800 Subject: [PATCH] CheatEnabler 2.2.1 --- CheatEnabler/CheatEnabler.csproj | 2 +- CheatEnabler/FactoryPatch.cs | 40 +++++++++++++++++++++--------- CheatEnabler/README.md | 16 ++++++++++++ CheatEnabler/package/manifest.json | 2 +- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/CheatEnabler/CheatEnabler.csproj b/CheatEnabler/CheatEnabler.csproj index 88612a8..d2f14fb 100644 --- a/CheatEnabler/CheatEnabler.csproj +++ b/CheatEnabler/CheatEnabler.csproj @@ -5,7 +5,7 @@ net472 org.soardev.cheatenabler DSP MOD - CheatEnabler - 2.2.0 + 2.2.1 true latest CheatEnabler diff --git a/CheatEnabler/FactoryPatch.cs b/CheatEnabler/FactoryPatch.cs index 9e99ccc..2a23f31 100644 --- a/CheatEnabler/FactoryPatch.cs +++ b/CheatEnabler/FactoryPatch.cs @@ -468,7 +468,7 @@ public static class FactoryPatch private static class NoConditionBuild { - [HarmonyTranspiler] + [HarmonyTranspiler, HarmonyPriority(Priority.Last)] [HarmonyPatch(typeof(BuildTool_Addon), nameof(BuildTool_Addon.CheckBuildConditions))] // [HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))] [HarmonyPatch(typeof(BuildTool_Inserter), nameof(BuildTool_Inserter.CheckBuildConditions))] @@ -479,13 +479,21 @@ public static class FactoryPatch yield return new CodeInstruction(OpCodes.Ret); } - [HarmonyTranspiler] + [HarmonyTranspiler, HarmonyPriority(Priority.Last)] [HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))] - private static IEnumerable BuildTool_Click_CheckBuildConditions_Transpiler(IEnumerable instructions) + private static IEnumerable BuildTool_Click_CheckBuildConditions_Transpiler(IEnumerable instructions, ILGenerator generator) { - yield return new CodeInstruction(OpCodes.Ldarg_0); - yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(NoConditionBuild), nameof(CheckForMiner))); - yield return new CodeInstruction(OpCodes.Ret); + var matcher = new CodeMatcher(instructions, generator); + var label1 = generator.DefineLabel(); + matcher.Start().InsertAndAdvance( + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(NoConditionBuild), nameof(CheckForMiner))), + new CodeInstruction(OpCodes.Brfalse_S, label1), + new CodeInstruction(OpCodes.Ldc_I4_1), + new CodeInstruction(OpCodes.Ret) + ); + matcher.Labels.Add(label1); + return matcher.InstructionEnumeration(); } public static bool CheckForMiner(BuildTool tool) @@ -1102,14 +1110,22 @@ public static class FactoryPatch var matcher = new CodeMatcher(instructions); matcher.Start().MatchForward(false, new CodeMatch(OpCodes.Ldc_R4, 110.25f) - ).Repeat(codeMatcher => codeMatcher.SetAndAdvance( - OpCodes.Ldc_R4, 1f - )); + ); + if (matcher.IsValid) + { + matcher.Repeat(codeMatcher => codeMatcher.SetAndAdvance( + OpCodes.Ldc_R4, 1f + )); + } matcher.Start().MatchForward(false, new CodeMatch(OpCodes.Ldc_R4, 144f) - ).Repeat(codeMatcher => codeMatcher.SetAndAdvance( - OpCodes.Ldc_R4, 1f - )); + ); + if (matcher.IsValid) + { + matcher.Repeat(codeMatcher => codeMatcher.SetAndAdvance( + OpCodes.Ldc_R4, 1f + )); + } return matcher.InstructionEnumeration(); } } diff --git a/CheatEnabler/README.md b/CheatEnabler/README.md index 9851252..8c651c5 100644 --- a/CheatEnabler/README.md +++ b/CheatEnabler/README.md @@ -4,6 +4,9 @@ #### 添加一些作弊功能,同时屏蔽异常检测 ## Changlog +* 2.2.1 + + Check condition for miners even when `Build without condition` is enabled. + + Fix a patch issue that may cause `Build without condition` not working. * 2.2.0 + Add some power related functions + Add a subfunction to belt signal item generation, which simulates production process of raws and intermediates on statistics @@ -58,6 +61,11 @@ + Solid flat on birth planet + High luminosity for birth star +## Notes +* Please upgrade `BepInEx` 5.4.21 or later if using with [BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/) to avoid possible conflicts. + + You can download `BepInEx` [here](https://github.com/bepinex/bepinex/releases/latest)(choose x64 edition). + + If using with r2modman, you can upgrade `BepInEx` by clicking `Settings` -> `Browse profile folder`, then extract downloaded zip to the folder and overwrite existing files. + ## CREDITS * [Dyson Sphere Program](https://store.steampowered.com/app/1366540): The great game * [BepInEx](https://bepinex.dev/): Base modding framework @@ -65,6 +73,9 @@ * [LSTM](https://github.com/hetima/DSP_LSTM) & [PlanetFinder](https://github.com/hetima/DSP_PlanetFinder): UI implementations ## 更新日志 +* 2.2.1 + + 即使在启用`无条件建造`时依然检查矿机的建造条件 + + 修复一个可能导致`无条件建造`不生效的问题 * 2.2.0 + 添加了一些发电相关功能 + 为传送带信号物品生成添加了一个子功能,在统计面板模拟了原材料和中间产物的生产过程 @@ -118,6 +129,11 @@ + 母星是纯平的 + 母星系恒星高亮 +## 注意事项 +* 如果和[BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/)一起使用,请升级`BepInEx`到5.4.21或更高版本,以避免可能的冲突。 + + 你可以在[这里](https://github.com/bepinex/bepinex/releases/latest)(选择x64版本)下载`BepInEx`。 + + 如果使用r2modman,你可以点击`Settings` -> `Browse profile folder`,然后将下载的zip解压到该文件夹并覆盖现有文件。 + ## 鸣谢 * [戴森球计划](https://store.steampowered.com/app/1366540): 伟大的游戏 * [BepInEx](https://bepinex.dev/): 基础模组框架 diff --git a/CheatEnabler/package/manifest.json b/CheatEnabler/package/manifest.json index 17f0ded..935e288 100644 --- a/CheatEnabler/package/manifest.json +++ b/CheatEnabler/package/manifest.json @@ -1,6 +1,6 @@ { "name": "CheatEnabler", - "version_number": "2.2.0", + "version_number": "2.2.1", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler", "description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测", "dependencies": [