Merge pull request #9 from DrParanoia/bugfix/fix_map_input

Fixed Controller/Keyboard Inputs not working when a Map is open
This commit is contained in:
Saty 2023-10-23 01:34:13 -07:00 committed by GitHub
commit 3f7dee3142
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,46 @@ 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
{
private static bool initialAllowInput = false;
static void Prefix(vp_FPInput __instance)
{
if (Globals.IsMultiplayer && Globals.PauseState == PauseState.Pause)
{
// 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;
}
}
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 = initialAllowInput;
}
}
}
[HarmonyPatch(typeof(PauseMenu))]
[HarmonyPatch("Update")]
class FIX_PauseMenu_Update