mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Add end game patches for all gamemodes
This commit is contained in:
1 parent
6fe2750545
commit
1c097b47df
1 file changed
+59
@@ -6,6 +6,23 @@ namespace MiraAPI.Patches.GameModes;
|
||||
[HarmonyPatch]
|
||||
internal static class GameLogicPatches
|
||||
{
|
||||
[HarmonyPrefix, HarmonyPatch(typeof(GameManager), nameof(GameManager.DidHumansWin))]
|
||||
public static bool DidHumansWin(GameOverReason reason, ref bool __result)
|
||||
{
|
||||
__result = reason == GameOverReason.CrewmatesByTask || reason == GameOverReason.CrewmatesByVote ||
|
||||
reason == GameOverReason.ImpostorDisconnect || reason == GameOverReason.HideAndSeek_CrewmatesByTimer;
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix, HarmonyPatch(typeof(GameManager), nameof(GameManager.DidImpostorsWin))]
|
||||
public static bool DidImpostorsWin(GameOverReason reason, ref bool __result)
|
||||
{
|
||||
__result = reason == GameOverReason.ImpostorsByKill || reason == GameOverReason.ImpostorsBySabotage ||
|
||||
reason == GameOverReason.ImpostorsByVote || reason == GameOverReason.HideAndSeek_ImpostorsByKills ||
|
||||
reason == GameOverReason.CrewmateDisconnect;
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix, HarmonyPatch(typeof(NormalGameManager), nameof(NormalGameManager.GetBodyType))]
|
||||
public static bool BodyTypePatch(NormalGameManager __instance, PlayerControl player, ref PlayerBodyTypes __result)
|
||||
{
|
||||
@@ -16,4 +33,46 @@ internal static class GameLogicPatches
|
||||
__result = CustomGameModeManager.ActiveMode.GetBodyType(player);
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(LogicGameFlowNormal), nameof(LogicGameFlowNormal.CheckEndCriteria))]
|
||||
public static bool EndGamePatch(LogicGameFlowNormal __instance)
|
||||
{
|
||||
if (TutorialManager.InstanceExists)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GameData.Instance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CustomGameModeManager.ActiveMode != null)
|
||||
{
|
||||
CustomGameModeManager.ActiveMode.CheckGameEnd(out var runOriginal, __instance);
|
||||
|
||||
if (!runOriginal)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(LogicGameFlowNormal), nameof(LogicGameFlowNormal.IsGameOverDueToDeath))]
|
||||
public static void IsGameOverDueToDeathPatch(LogicGameFlowNormal __instance, ref bool __result)
|
||||
{
|
||||
if (CustomGameModeManager.IsActiveGameMode<HideAndSeekMode>())
|
||||
{
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user