diff --git a/MiraAPI/GameModes/AbstractGameMode.cs b/MiraAPI/GameModes/AbstractGameMode.cs index 93d97bc..cd35deb 100644 --- a/MiraAPI/GameModes/AbstractGameMode.cs +++ b/MiraAPI/GameModes/AbstractGameMode.cs @@ -37,6 +37,11 @@ public abstract class AbstractGameMode : IOptionable /// public virtual bool GameModeBodyTypeOverride => false; + /// + /// Gets a value indicating whether the gamemode is based on Hide n Seek. + /// + public virtual bool IsHideAndSeek => false; + /// /// Called on GameManager.GetBodyType(). /// diff --git a/MiraAPI/GameModes/HideAndSeekMode.cs b/MiraAPI/GameModes/HideAndSeekMode.cs index e10526b..5645141 100644 --- a/MiraAPI/GameModes/HideAndSeekMode.cs +++ b/MiraAPI/GameModes/HideAndSeekMode.cs @@ -29,6 +29,7 @@ public class HideAndSeekMode : AbstractGameMode public override bool ShouldShowSabotageMap(MapBehaviour map) => false; public override bool ShowGameModeIntroCutscene => true; public override bool GameModeBodyTypeOverride => true; + public override bool IsHideAndSeek => true; public override IEnumerator IntroCutscene(IntroCutscene __instance) { @@ -226,6 +227,7 @@ public class HideAndSeekMode : AbstractGameMode public override void OnPlayerDeath(PlayerControl player, bool assignGhostRole) { base.OnPlayerDeath(player, assignGhostRole); + HudManager.Instance.NotifyOfDeath(); var popup = GameManagerCreator.Instance.HideAndSeekManagerPrefab.DeathPopupPrefab; deadPlayerCount++; var item = UnityEngine.Object.Instantiate(popup, HudManager.Instance.transform.parent); diff --git a/MiraAPI/Patches/GameModes/GameManagerPatches.cs b/MiraAPI/Patches/GameModes/GameManagerPatches.cs new file mode 100644 index 0000000..7467d9e --- /dev/null +++ b/MiraAPI/Patches/GameModes/GameManagerPatches.cs @@ -0,0 +1,31 @@ +using HarmonyLib; +using MiraAPI.GameModes; + +namespace MiraAPI.Patches.GameModes; + +[HarmonyPatch(typeof(GameManager))] +internal static class GameManagerPatches +{ + [HarmonyPrefix, HarmonyPatch(nameof(GameManager.OnPlayerDeath))] + public static bool OnDeathPrefix([HarmonyArgument(0)] PlayerControl player, [HarmonyArgument(1)] bool assignGhostRole) + { + if (CustomGameModeManager.ActiveMode != null) + { + CustomGameModeManager.ActiveMode.OnPlayerDeath(player, assignGhostRole); + return false; + } + + return true; + } + [HarmonyPrefix, HarmonyPatch(nameof(GameManager.ShowCrewmatesKilled))] + public static bool ShowCrewmatesKilledPrefix(ref bool __result) + { + if (CustomGameModeManager.ActiveMode != null) + { + __result = CustomGameModeManager.ActiveMode.IsHideAndSeek; + return false; + } + + return true; + } +} diff --git a/MiraAPI/Patches/GameModes/NormalGameManagerPatches.cs b/MiraAPI/Patches/GameModes/NormalGameManagerPatches.cs new file mode 100644 index 0000000..bed43b9 --- /dev/null +++ b/MiraAPI/Patches/GameModes/NormalGameManagerPatches.cs @@ -0,0 +1,20 @@ +using HarmonyLib; +using MiraAPI.GameModes; + +namespace MiraAPI.Patches.GameModes; + +[HarmonyPatch(typeof(NormalGameManager))] +internal static class NormalGameManagerPatches +{ + [HarmonyPrefix, HarmonyPatch(nameof(NormalGameManager.IsNormal))] + public static bool IsNormal(ref bool __result) + { + if (CustomGameModeManager.ActiveMode != null) + { + __result = !CustomGameModeManager.ActiveMode.IsHideAndSeek; + return false; + } + + return true; + } +} diff --git a/MiraAPI/Patches/GameModes/OnDeathPatch.cs b/MiraAPI/Patches/GameModes/OnDeathPatch.cs deleted file mode 100644 index 82a16f6..0000000 --- a/MiraAPI/Patches/GameModes/OnDeathPatch.cs +++ /dev/null @@ -1,20 +0,0 @@ -using HarmonyLib; -using MiraAPI.GameModes; - -namespace MiraAPI.Patches.GameModes; - -[HarmonyPatch(typeof(GameManager))] -internal static class OnDeathPatch -{ - [HarmonyPrefix, HarmonyPatch(nameof(GameManager.OnPlayerDeath))] - public static bool OnDeathPostfix([HarmonyArgument(0)] PlayerControl player, [HarmonyArgument(1)] bool assignGhostRole) - { - if (CustomGameModeManager.ActiveMode != null) - { - CustomGameModeManager.ActiveMode.OnPlayerDeath(player, assignGhostRole); - return false; - } - - return true; - } -}