mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-19 15:51:58 +00:00
43 lines
1.3 KiB
C#
43 lines
1.3 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);
|
|
Main.Instance.Harmony.UnpatchSelf();
|
|
#if IL2CPP
|
|
Main.Instance.Unload();
|
|
#else
|
|
Object.Destroy(Main.Instance.gameObject);
|
|
#endif
|
|
}
|
|
} |