From d0bc5cf1d44d61ff4967d8b3bcf3b7840af98f5c Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Sat, 7 Oct 2023 16:46:13 +0800 Subject: [PATCH] CheatEnabler v2.2.7 --- CheatEnabler/CheatEnabler.cs | 2 ++ CheatEnabler/CheatEnabler.csproj | 2 +- CheatEnabler/DysonSpherePatch.cs | 54 +++++++++++++++++++++++++++++- CheatEnabler/FactoryPatch.cs | 3 ++ CheatEnabler/README.md | 14 +++++++- CheatEnabler/ResourcePatch.cs | 8 ++--- CheatEnabler/UIConfigWindow.cs | 3 ++ CheatEnabler/package/manifest.json | 2 +- 8 files changed, 79 insertions(+), 9 deletions(-) diff --git a/CheatEnabler/CheatEnabler.cs b/CheatEnabler/CheatEnabler.cs index 719e94a..f69c8d0 100644 --- a/CheatEnabler/CheatEnabler.cs +++ b/CheatEnabler/CheatEnabler.cs @@ -73,6 +73,8 @@ public class CheatEnabler : BaseUnityPlugin "Can do terraform without enough sands"); DysonSpherePatch.StopEjectOnNodeCompleteEnabled = Config.Bind("DysonSphere", "StopEjectOnNodeComplete", false, "Stop ejectors when available nodes are all filled up"); + DysonSpherePatch.OnlyConstructNodesEnabled = Config.Bind("DysonSphere", "OnlyConstructNodes", false, + "Construct only nodes but frames"); DysonSpherePatch.SkipBulletEnabled = Config.Bind("DysonSphere", "SkipBullet", false, "Skip bullet"); DysonSpherePatch.SkipAbsorbEnabled = Config.Bind("DysonSphere", "SkipAbsorb", false, diff --git a/CheatEnabler/CheatEnabler.csproj b/CheatEnabler/CheatEnabler.csproj index 54b75d6..e2b1493 100644 --- a/CheatEnabler/CheatEnabler.csproj +++ b/CheatEnabler/CheatEnabler.csproj @@ -5,7 +5,7 @@ net472 org.soardev.cheatenabler DSP MOD - CheatEnabler - 2.2.6 + 2.2.7 true latest CheatEnabler diff --git a/CheatEnabler/DysonSpherePatch.cs b/CheatEnabler/DysonSpherePatch.cs index ed460dc..d0667bf 100644 --- a/CheatEnabler/DysonSpherePatch.cs +++ b/CheatEnabler/DysonSpherePatch.cs @@ -9,6 +9,7 @@ namespace CheatEnabler; public static class DysonSpherePatch { public static ConfigEntry StopEjectOnNodeCompleteEnabled; + public static ConfigEntry OnlyConstructNodesEnabled; public static ConfigEntry SkipBulletEnabled; public static ConfigEntry SkipAbsorbEnabled; public static ConfigEntry QuickAbsorbEnabled; @@ -22,6 +23,7 @@ public static class DysonSpherePatch { _dysonSpherePatch ??= Harmony.CreateAndPatchAll(typeof(DysonSpherePatch)); StopEjectOnNodeCompleteEnabled.SettingChanged += (_, _) => StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value); + OnlyConstructNodesEnabled.SettingChanged += (_, _) => OnlyConstructNodes.Enable(OnlyConstructNodesEnabled.Value); SkipBulletEnabled.SettingChanged += (_, _) => SkipBulletPatch.Enable(SkipBulletEnabled.Value); SkipAbsorbEnabled.SettingChanged += (_, _) => SkipAbsorbPatch.Enable(SkipBulletEnabled.Value); QuickAbsorbEnabled.SettingChanged += (_, _) => QuickAbsorbPatch.Enable(QuickAbsorbEnabled.Value); @@ -29,6 +31,7 @@ public static class DysonSpherePatch OverclockEjectorEnabled.SettingChanged += (_, _) => OverclockEjector.Enable(OverclockEjectorEnabled.Value); OverclockSiloEnabled.SettingChanged += (_, _) => OverclockSilo.Enable(OverclockSiloEnabled.Value); StopEjectOnNodeComplete.Enable(StopEjectOnNodeCompleteEnabled.Value); + OnlyConstructNodes.Enable(OnlyConstructNodesEnabled.Value); SkipBulletPatch.Enable(SkipBulletEnabled.Value); SkipAbsorbPatch.Enable(SkipBulletEnabled.Value); QuickAbsorbPatch.Enable(QuickAbsorbEnabled.Value); @@ -40,6 +43,7 @@ public static class DysonSpherePatch public static void Uninit() { StopEjectOnNodeComplete.Enable(false); + OnlyConstructNodes.Enable(false); SkipBulletPatch.Enable(false); SkipAbsorbPatch.Enable(false); QuickAbsorbPatch.Enable(false); @@ -158,7 +162,6 @@ public static class DysonSpherePatch private static void SetNodeForAbsorb(int index, int layerId, int nodeId, bool canAbsorb) { - CheatEnabler.Logger.LogDebug($"{index} {layerId} {nodeId} {canAbsorb}"); ref var comp = ref _nodeForAbsorb[index]; comp ??= new HashSet(); var idx = nodeId * 10 + layerId; @@ -284,6 +287,55 @@ public static class DysonSpherePatch } } + private static class OnlyConstructNodes + { + private static Harmony _patch; + + public static void Enable(bool on) + { + if (on) + { + _patch ??= Harmony.CreateAndPatchAll(typeof(OnlyConstructNodes)); + } + else + { + _patch?.UnpatchSelf(); + _patch = null; + } + + var spheres = GameMain.data?.dysonSpheres; + if (spheres == null) return; + foreach (var sphere in spheres) + { + if (sphere == null) continue; + sphere.CheckAutoNodes(); + if (sphere.autoNodeCount > 0) continue; + sphere.PickAutoNode(); + sphere.PickAutoNode(); + sphere.PickAutoNode(); + sphere.PickAutoNode(); + } + } + + [HarmonyTranspiler] + [HarmonyPatch(typeof(DysonNode), nameof(DysonNode.spReqOrder), MethodType.Getter)] + private static IEnumerable DysonNode_spReqOrder_Getter_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + matcher.MatchForward(false, + new CodeMatch(OpCodes.Ldarg_0), + new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode._spReq))) + ).Advance(1).SetInstructionAndAdvance( + new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode.spMax))) + ).Insert( + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(DysonNode), nameof(DysonNode.sp))), + new CodeInstruction(OpCodes.Sub) + ); + return matcher.InstructionEnumeration(); + } + } + private static class SkipBulletPatch { private static long _sailLifeTime; diff --git a/CheatEnabler/FactoryPatch.cs b/CheatEnabler/FactoryPatch.cs index 88b0c51..e21d10f 100644 --- a/CheatEnabler/FactoryPatch.cs +++ b/CheatEnabler/FactoryPatch.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Net; using System.Reflection.Emit; using BepInEx.Configuration; using HarmonyLib; @@ -620,6 +621,7 @@ public static class FactoryPatch public static void OnAltFormatChanged() { + if (_signalBelts == null) return; var factories = GameMain.data?.factories; if (factories == null) return; var factoryCount = GameMain.data.factoryCount; @@ -632,6 +634,7 @@ public static class FactoryPatch var entitySignPool = factory.entitySignPool; if (entitySignPool == null) continue; var belts = _signalBelts[i]; + if (belts == null) continue; foreach (var pair in belts) { var beltId = pair.Key; diff --git a/CheatEnabler/README.md b/CheatEnabler/README.md index 23a695b..a1844f0 100644 --- a/CheatEnabler/README.md +++ b/CheatEnabler/README.md @@ -4,6 +4,11 @@ #### 添加一些作弊功能,同时屏蔽异常检测 ## Changlog +* 2.2.7 + + New function: `Construct only nodes but frames` + + Opening config panel does not close inventory panel now + + Remove `Input direction conflict` check while using `Remove some build conditions` + + Fix a bug that prevents `Belt signal alt format` from switching number formats for current belt signals * 2.2.6 + New function: `Stop ejectors when available nodes are all filled up` + Fix a bug that absorb solar sails on unfinised nodes @@ -72,7 +77,8 @@ + Re-intialize planet (without reseting veins) + Quick dismantle all buildings (without drops) + Dyson Sphere: - + Stop ejectors when available nodes are all filled up + + Stop ejectors when available nodes are all filled up + + Construct only nodes but frames + Skip bullet period + Skip absorption period + Quick absorb @@ -96,6 +102,11 @@ * [LSTM](https://github.com/hetima/DSP_LSTM) & [PlanetFinder](https://github.com/hetima/DSP_PlanetFinder): UI implementations ## 更新日志 +* 2.2.7 + + 新功能:`只建造节点不建造框架` + + 打开设置面板时不再关闭背包面板 + + 在`移除部分不影响游戏逻辑的建造条件`启用时移除`输入方向冲突`的检查条件 + + 修复导致`传送带信号替换格式`不切换传送带信号数字格式的问题 * 2.2.6 + 新功能:`可用节点全部造完时停止弹射` + 修复了在未完成的节点上吸收太阳帆的问题 @@ -165,6 +176,7 @@ + 快速拆除所有建筑(不掉落) + 戴森球: + 可用节点全部造完时停止弹射 + + 只建造节点不建造框架 + 跳过子弹阶段 + 跳过吸收阶段 + 快速吸收 diff --git a/CheatEnabler/ResourcePatch.cs b/CheatEnabler/ResourcePatch.cs index e952632..0b1aa4e 100644 --- a/CheatEnabler/ResourcePatch.cs +++ b/CheatEnabler/ResourcePatch.cs @@ -40,11 +40,10 @@ public static class ResourcePatch _patch = null; } } - + [HarmonyTranspiler] [HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool))] - [HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool), typeof(int), typeof(int), - typeof(int))] + [HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool), typeof(int), typeof(int), typeof(int))] [HarmonyPatch(typeof(ItemProto), "GetPropValue")] [HarmonyPatch(typeof(PlanetTransport), "GameTick")] [HarmonyPatch(typeof(UIMinerWindow), "_OnUpdate")] @@ -89,8 +88,7 @@ public static class ResourcePatch [HarmonyTranspiler] [HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool))] - [HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool), typeof(int), typeof(int), - typeof(int))] + [HarmonyPatch(typeof(FactorySystem), "GameTick", typeof(long), typeof(bool), typeof(int), typeof(int), typeof(int))] [HarmonyPatch(typeof(ItemProto), "GetPropValue")] [HarmonyPatch(typeof(PlanetTransport), "GameTick")] [HarmonyPatch(typeof(UIMinerWindow), "_OnUpdate")] diff --git a/CheatEnabler/UIConfigWindow.cs b/CheatEnabler/UIConfigWindow.cs index 599fd19..9ec1983 100644 --- a/CheatEnabler/UIConfigWindow.cs +++ b/CheatEnabler/UIConfigWindow.cs @@ -53,6 +53,7 @@ public class UIConfigWindow : UI.MyWindowWithTabs I18N.Add("Dismantle All Buildings", "Dismantle all buildings", "拆除所有建筑"); I18N.Add("Dyson Sphere", "Dyson Sphere", "戴森球"); I18N.Add("Stop ejectors when available nodes are all filled up", "Stop ejectors when available nodes are all filled up", "可用节点全部造完时停止弹射"); + I18N.Add("Construct only nodes but frames", "Construct only nodes but frames", "只造节点不造框架"); I18N.Add("Skip bullet period", "Skip bullet period", "跳过子弹阶段"); I18N.Add("Skip absorption period", "Skip absorption period", "跳过吸收阶段"); I18N.Add("Quick absorb", "Quick absorb", "快速吸收"); @@ -206,6 +207,8 @@ public class UIConfigWindow : UI.MyWindowWithTabs y = 10f; UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.StopEjectOnNodeCompleteEnabled, "Stop ejectors when available nodes are all filled up"); y += 36f; + UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OnlyConstructNodesEnabled, "Construct only nodes but frames"); + y += 36f; UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.SkipBulletEnabled, "Skip bullet period"); y += 36f; UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.SkipAbsorbEnabled, "Skip absorption period"); diff --git a/CheatEnabler/package/manifest.json b/CheatEnabler/package/manifest.json index f103337..452fdd0 100644 --- a/CheatEnabler/package/manifest.json +++ b/CheatEnabler/package/manifest.json @@ -1,6 +1,6 @@ { "name": "CheatEnabler", - "version_number": "2.2.6", + "version_number": "2.2.7", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler", "description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测", "dependencies": [