mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using AmongUs.GameOptions;
|
|
using HarmonyLib;
|
|
|
|
namespace EHR.Patches;
|
|
|
|
[HarmonyPatch(typeof(GameOptionsManager), nameof(GameOptionsManager.SwitchGameMode))]
|
|
internal static class SwitchGameModePatch
|
|
{
|
|
private static bool Warned;
|
|
|
|
public static bool Prefix(GameModes gameMode)
|
|
{
|
|
if (!Options.IsLoaded || (AmongUsClient.Instance != null && !AmongUsClient.Instance.AmHost && PlayerControl.LocalPlayer != null) || gameMode != GameModes.HideNSeek || Warned || !HudManager.Instance) return true;
|
|
|
|
ModUpdater.ShowPopup(Translator.GetString("HnSUnloadWarning"), StringNames.OkayDontShow, true, false);
|
|
return false;
|
|
}
|
|
|
|
public static void Postfix(GameModes gameMode)
|
|
{
|
|
if (!Options.IsLoaded || (!AmongUsClient.Instance.AmHost && PlayerControl.LocalPlayer != null) || gameMode != GameModes.HideNSeek) return;
|
|
|
|
if (!Warned)
|
|
{
|
|
Warned = true;
|
|
return;
|
|
}
|
|
|
|
if (ErrorText.Instance != null)
|
|
{
|
|
ErrorText.Instance.HnSFlag = true;
|
|
ErrorText.Instance.AddError(ErrorCode.HnsUnload);
|
|
}
|
|
|
|
Zoom.SetZoomSize(reset: true);
|
|
Harmony.UnpatchAll();
|
|
Main.Instance.Unload();
|
|
}
|
|
} |