diff --git a/plugin_template/swinfo.json b/plugin_template/swinfo.json index 54f3184..0fe152e 100644 --- a/plugin_template/swinfo.json +++ b/plugin_template/swinfo.json @@ -5,7 +5,7 @@ "name": "Where's My Crew Capsule (Modules)", "description": "The modules used for Where's My Crew Capsule", "source": "https://github.com/cheese3660/WMCCModules", - "version": "0.1.0", + "version": "0.2.0", "version_check": "https://raw.githubusercontent.com/cheese3660/WMCCModules/main/plugin_template/swinfo.json", "ksp2_version": { "min": "0.1.5", @@ -15,7 +15,7 @@ { "id": "com.github.x606.spacewarp", "version": { - "min": "1.6.0", + "min": "1.7.0", "max": "*" } } diff --git a/src/WMCCModules/Patches/PartComponentModule_CommandPatch.cs b/src/WMCCModules/Patches/PartComponentModule_CommandPatch.cs index 818b187..cce1c79 100644 --- a/src/WMCCModules/Patches/PartComponentModule_CommandPatch.cs +++ b/src/WMCCModules/Patches/PartComponentModule_CommandPatch.cs @@ -10,13 +10,14 @@ namespace WMCCModules.Patches; public class PartComponentModule_CommandPatch { [HarmonyPatch(nameof(PartComponentModule_Command.UpdateControlStatus))] - [HarmonyPrefix] - public static bool UpdateControlStatus(PartComponentModule_Command __instance) + [HarmonyPostfix] + public static void UpdateControlStatus(PartComponentModule_Command __instance) { - if (!__instance.Part.Modules.TryGetValue(typeof(PartComponentModule_ControlRange), out var comp)) return true; + if (!WMCCModulesPlugin.Instance.EnableControlRange.Value) return; + if (!__instance.Part.Modules.TryGetValue(typeof(PartComponentModule_ControlRange), out var comp)) return; var mcr = comp as PartComponentModule_ControlRange; - if (mcr!.DataControlRange == null || mcr.DataControlRange.Controllable) return true; - __instance.dataCommand.controlStatus.SetValue(CommandControlState.NoCommNetConnection); - return false; + if (mcr!.DataControlRange == null || mcr.DataControlRange.Controllable) return; + if (__instance.dataCommand.controlStatus.GetValue() == CommandControlState.FullyFunctional) + __instance.dataCommand.controlStatus.SetValue(CommandControlState.Hibernating); } } \ No newline at end of file diff --git a/src/WMCCModules/WMCCModulesPlugin.cs b/src/WMCCModules/WMCCModulesPlugin.cs index 64ddcdc..bffa327 100644 --- a/src/WMCCModules/WMCCModulesPlugin.cs +++ b/src/WMCCModules/WMCCModulesPlugin.cs @@ -1,7 +1,9 @@ using BepInEx; +using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using SpaceWarp; +using SpaceWarp.API.Configuration; using SpaceWarp.API.Mods; using WMCCModules.Patches; @@ -18,6 +20,12 @@ public class WMCCModulesPlugin : BaseSpaceWarpPlugin // Singleton instance of the plugin class [PublicAPI] public static WMCCModulesPlugin Instance { get; set; } + public ConfigValue EnableControlRange; + private void Start() + { + EnableControlRange = new ConfigValue(SWConfiguration.Bind("Module Settings", "Enable Control Range", true, + "Enable the control range module (what forces you to lose control in certain situations until you unlock a certain tech node)")); + } /// /// Runs when the mod is first initialized.