From 1cfdedf2698aa3e96f41c51213d2784e02d69d19 Mon Sep 17 00:00:00 2001 From: Arturs Ziborovs Date: Sun, 22 Oct 2023 20:25:01 +0300 Subject: [PATCH 1/5] 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 From 8d835a349cd5871a128bf8cb878518ffcb5e52b0 Mon Sep 17 00:00:00 2001 From: Arturs Ziborovs Date: Sun, 22 Oct 2023 20:29:16 +0300 Subject: [PATCH 2/5] Fixed unneeded space --- SRMP/Patches/Patch_PauseFix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SRMP/Patches/Patch_PauseFix.cs b/SRMP/Patches/Patch_PauseFix.cs index f6cea86..40f08ef 100644 --- a/SRMP/Patches/Patch_PauseFix.cs +++ b/SRMP/Patches/Patch_PauseFix.cs @@ -68,7 +68,7 @@ namespace SRMultiplayer.Patches prevAllowInput = __instance.m_AllowGameplayInput; if (Globals.IsMultiplayer && Globals.PauseState == PauseState.Pause) { - // Disable input so that we don't move when "paused" + // Disable input so that we don't move when "paused" __instance.m_AllowGameplayInput = false; } } From b9de510fa57a7bdf8dafe8bf9f36c9a4f87b74ef Mon Sep 17 00:00:00 2001 From: Arturs Ziborovs Date: Sun, 22 Oct 2023 20:45:37 +0300 Subject: [PATCH 3/5] Slightly better state management --- SRMP/Patches/Patch_PauseFix.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SRMP/Patches/Patch_PauseFix.cs b/SRMP/Patches/Patch_PauseFix.cs index 40f08ef..5f3a124 100644 --- a/SRMP/Patches/Patch_PauseFix.cs +++ b/SRMP/Patches/Patch_PauseFix.cs @@ -61,14 +61,16 @@ namespace SRMultiplayer.Patches [HarmonyPatch("Update")] class FIX_FPInput_Pause { - private static bool prevAllowInput = false; + private static bool initialAllowInput = 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" + // Save the initial state of the input + initialAllowInput = __instance.m_AllowGameplayInput; + + // Disable input so that we don't move when "paused" __instance.m_AllowGameplayInput = false; } } @@ -79,7 +81,7 @@ namespace SRMultiplayer.Patches { // 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; + __instance.m_AllowGameplayInput = initialAllowInput; } } } From 2092a9f7247b1925dfea544264094b7287d95435 Mon Sep 17 00:00:00 2001 From: Arturs Ziborovs Date: Sun, 22 Oct 2023 20:46:15 +0300 Subject: [PATCH 4/5] Removed a space --- SRMP/Patches/Patch_PauseFix.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SRMP/Patches/Patch_PauseFix.cs b/SRMP/Patches/Patch_PauseFix.cs index 5f3a124..26d1f81 100644 --- a/SRMP/Patches/Patch_PauseFix.cs +++ b/SRMP/Patches/Patch_PauseFix.cs @@ -70,7 +70,7 @@ namespace SRMultiplayer.Patches // Save the initial state of the input initialAllowInput = __instance.m_AllowGameplayInput; - // Disable input so that we don't move when "paused" + // Disable input so that we don't move when "paused" __instance.m_AllowGameplayInput = false; } } From 159032dd840e5eb4f11d9bd780214f1d2f80ecfc Mon Sep 17 00:00:00 2001 From: Arturs Ziborovs Date: Mon, 23 Oct 2023 02:32:01 +0300 Subject: [PATCH 5/5] Fixed Map being broken again after dying --- SRMP/Patches/Patch_PauseFix.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/SRMP/Patches/Patch_PauseFix.cs b/SRMP/Patches/Patch_PauseFix.cs index 26d1f81..13d4105 100644 --- a/SRMP/Patches/Patch_PauseFix.cs +++ b/SRMP/Patches/Patch_PauseFix.cs @@ -57,6 +57,17 @@ namespace SRMultiplayer.Patches } } + [HarmonyPatch(typeof(MapUI))] + [HarmonyPatch("OpenMap")] + class FIX_MapUI_OpenMap + { + static void Postfix(MapUI __instance) + { + // Fix input mode not refreshing after dying + SRInput.instance.SetInputMode(SRInput.InputMode.PAUSE); + } + } + [HarmonyPatch(typeof(vp_FPInput))] [HarmonyPatch("Update")] class FIX_FPInput_Pause