diff --git a/CheatEnabler/CHANGELOG.md b/CheatEnabler/CHANGELOG.md index 012fece..503e1cc 100644 --- a/CheatEnabler/CHANGELOG.md +++ b/CheatEnabler/CHANGELOG.md @@ -1,5 +1,7 @@ ## Changlog +* 2.3.25 + + New feature: `Enable warp without space warpers` * 2.3.24 + `Complete Dyson Sphere Shells instantly`: Fix a bug that may cause negative power in some cases * 2.3.23 @@ -127,6 +129,8 @@ ## 更新日志 +* 2.3.25 + + 新功能:`无需空间翘曲器即可曲速飞行` * 2.3.24 + `立即完成戴森壳建造`:修复了在某些情况下可能导致发电为负的问题 * 2.3.23 diff --git a/CheatEnabler/CheatEnabler.cs b/CheatEnabler/CheatEnabler.cs index 8061dd3..d2f2c05 100644 --- a/CheatEnabler/CheatEnabler.cs +++ b/CheatEnabler/CheatEnabler.cs @@ -58,6 +58,8 @@ public class CheatEnabler : BaseUnityPlugin "Can do terraform without enough soil piless"); PlayerPatch.InstantTeleportEnabled = Config.Bind("Player", "InstantTeleport", false, "Enable instant teleport (like that in Sandbox mode)"); + PlayerPatch.WarpWithoutSpaceWarpersEnabled = Config.Bind("Player", "WarpWithoutWarper", false, + "Enable warp without warper"); DysonSpherePatch.SkipBulletEnabled = Config.Bind("DysonSphere", "SkipBullet", false, "Skip bullet"); DysonSpherePatch.SkipAbsorbEnabled = Config.Bind("DysonSphere", "SkipAbsorb", false, diff --git a/CheatEnabler/FactoryPatch.cs b/CheatEnabler/FactoryPatch.cs index 7266041..da17725 100644 --- a/CheatEnabler/FactoryPatch.cs +++ b/CheatEnabler/FactoryPatch.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Reflection.Emit; using BepInEx.Configuration; using CommonAPI.Systems; diff --git a/CheatEnabler/PlayerPatch.cs b/CheatEnabler/PlayerPatch.cs index 9373b75..e6642fe 100644 --- a/CheatEnabler/PlayerPatch.cs +++ b/CheatEnabler/PlayerPatch.cs @@ -8,16 +8,20 @@ namespace CheatEnabler; public static class PlayerPatch { public static ConfigEntry InstantTeleportEnabled; + public static ConfigEntry WarpWithoutSpaceWarpersEnabled; public static void Init() { InstantTeleportEnabled.SettingChanged += (_, _) => InstantTeleport.Enable(InstantTeleportEnabled.Value); + WarpWithoutSpaceWarpersEnabled.SettingChanged += (_, _) => WarpWithoutSpaceWarpers.Enable(WarpWithoutSpaceWarpersEnabled.Value); InstantTeleport.Enable(InstantTeleportEnabled.Value); + WarpWithoutSpaceWarpers.Enable(WarpWithoutSpaceWarpersEnabled.Value); } public static void Uninit() { InstantTeleport.Enable(false); + WarpWithoutSpaceWarpers.Enable(false); } private static class InstantTeleport @@ -57,4 +61,37 @@ public static class PlayerPatch return matcher.InstructionEnumeration(); } } -} \ No newline at end of file + + private static class WarpWithoutSpaceWarpers + { + private static Harmony _patch; + + public static void Enable(bool on) + { + if (on) + { + _patch ??= Harmony.CreateAndPatchAll(typeof(WarpWithoutSpaceWarpers)); + } + else + { + _patch?.UnpatchSelf(); + _patch = null; + } + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(Mecha), nameof(Mecha.HasWarper))] + private static bool Mecha_HasWarper_Prefix(ref bool __result) + { + __result = true; + return false; + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(Mecha), nameof(Mecha.UseWarper))] + private static void Mecha_UseWarper_Postfix(ref bool __result) + { + __result = true; + } + } +} diff --git a/CheatEnabler/README.md b/CheatEnabler/README.md index ec32512..bd28863 100644 --- a/CheatEnabler/README.md +++ b/CheatEnabler/README.md @@ -47,6 +47,7 @@ + Mecha/Combat: + Mecha and Drones/Fleets invicible + Buildings invicible + + Enable warp without space warpers + Teleport to outer space + Teleport to selected astronomical @@ -102,9 +103,12 @@ + 快速吸收 + 全球弹射 + 立即完成戴森壳建造 - + 战斗: + + 机甲/战斗: + 机甲和战斗无人机无敌 + 建筑无敌 + + 无需空间翘曲器即可曲速飞行 + + 传送到外太空 + + 传送到选定的天体 ## 注意事项 * 如果和[BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/)一起使用,请升级`BepInEx`到5.4.21或更高版本,以避免可能的冲突 diff --git a/CheatEnabler/UIConfigWindow.cs b/CheatEnabler/UIConfigWindow.cs index 3d36b89..d958000 100644 --- a/CheatEnabler/UIConfigWindow.cs +++ b/CheatEnabler/UIConfigWindow.cs @@ -66,6 +66,7 @@ public static class UIConfigWindow I18N.Add("Instant teleport (like that in Sandbox mode)", "Instant teleport (like that in Sandbox mode)", "快速传送(和沙盒模式一样)"); I18N.Add("Mecha and Drones/Fleets invicible", "Mecha and Drones/Fleets invicible", "机甲和战斗无人机无敌"); I18N.Add("Buildings invicible", "Buildings invincible", "建筑无敌"); + I18N.Add("Enable warp without space warpers", "Enable warp without space warpers", "无需空间翘曲器即可曲速飞行"); I18N.Add("Teleport to outer space", "Teleport to outer space", "传送到外太空"); I18N.Add("Teleport to selected astronomical", "Teleport to selected astronomical", "传送到选中的天体"); I18N.Apply(); @@ -215,6 +216,8 @@ public static class UIConfigWindow wnd.AddCheckBox(x, y, tab5, CombatPatch.MechaInvincibleEnabled, "Mecha and Drones/Fleets invicible"); y += 36f; wnd.AddCheckBox(x, y, tab5, CombatPatch.BuildingsInvincibleEnabled, "Buildings invicible"); + y += 36f; + wnd.AddCheckBox(x, y, tab5, PlayerPatch.WarpWithoutSpaceWarpersEnabled, "Enable warp without space warpers"); x = 400f; y = 10f; wnd.AddButton(x, y, 200f, tab5, "Teleport to outer space", 16, "button-teleport-to-outer-space", PlayerFunctions.TeleportToOuterSpace);