Skip to content

Commit

Permalink
Merge pull request #1 from cheese3660/dev
Browse files Browse the repository at this point in the history
Dev -> Main
  • Loading branch information
cheese3660 authored Jan 4, 2024
2 parents 47e0cbc + 5a73de7 commit 5d62f48
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions plugin_template/swinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -15,7 +15,7 @@
{
"id": "com.github.x606.spacewarp",
"version": {
"min": "1.6.0",
"min": "1.7.0",
"max": "*"
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/WMCCModules/Patches/PartComponentModule_CommandPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
8 changes: 8 additions & 0 deletions src/WMCCModules/WMCCModulesPlugin.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -18,6 +20,12 @@ public class WMCCModulesPlugin : BaseSpaceWarpPlugin

// Singleton instance of the plugin class
[PublicAPI] public static WMCCModulesPlugin Instance { get; set; }
public ConfigValue<bool> EnableControlRange;
private void Start()
{
EnableControlRange = new ConfigValue<bool>(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)"));
}

/// <summary>
/// Runs when the mod is first initialized.
Expand Down

0 comments on commit 5d62f48

Please sign in to comment.