From 1cfdedf2698aa3e96f41c51213d2784e02d69d19 Mon Sep 17 00:00:00 2001 From: Arturs Ziborovs Date: Sun, 22 Oct 2023 20:25:01 +0300 Subject: [PATCH] Fixed Controller/Keyboard Inputs not working when a Map is open --- SRMP/Patches/Patch_PauseFix.cs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/SRMP/Patches/Patch_PauseFix.cs b/SRMP/Patches/Patch_PauseFix.cs index f17a13f..f6cea86 100644 --- a/SRMP/Patches/Patch_PauseFix.cs +++ b/SRMP/Patches/Patch_PauseFix.cs @@ -48,7 +48,7 @@ namespace SRMultiplayer.Patches if (Globals.PauseState == PauseState.Pause) { - __instance.actions.Enabled = false; + __instance.actions.Enabled = true; __instance.pauseActions.Enabled = true; __instance.engageActions.Enabled = false; return false; @@ -57,6 +57,33 @@ namespace SRMultiplayer.Patches } } + [HarmonyPatch(typeof(vp_FPInput))] + [HarmonyPatch("Update")] + class FIX_FPInput_Pause + { + private static bool prevAllowInput = false; + + static void Prefix(vp_FPInput __instance) + { + prevAllowInput = __instance.m_AllowGameplayInput; + if (Globals.IsMultiplayer && Globals.PauseState == PauseState.Pause) + { + // Disable input so that we don't move when "paused" + __instance.m_AllowGameplayInput = false; + } + } + + static void Postfix(vp_FPInput __instance) + { + if (Globals.IsMultiplayer && Globals.PauseState == PauseState.Pause) + { + // Restore any initial value after we've blocked the input + // since I have no idea if it should have been initially disabled + __instance.m_AllowGameplayInput = prevAllowInput; + } + } + } + [HarmonyPatch(typeof(PauseMenu))] [HarmonyPatch("Update")] class FIX_PauseMenu_Update