diff --git a/MiraAPI/GameEnd/CustomGameOver.cs b/MiraAPI/GameEnd/CustomGameOver.cs index e54c750..7f3d43a 100644 --- a/MiraAPI/GameEnd/CustomGameOver.cs +++ b/MiraAPI/GameEnd/CustomGameOver.cs @@ -15,6 +15,15 @@ public abstract class CustomGameOver /// public static CustomGameOver? Instance { get; internal set; } + /// + /// Verifies if the condition for this CustomGameOver is met. + /// + /// True if the condition is met, otherwise false. + public virtual bool VerifyCondition() + { + return true; + } + /// /// Runs before the base game calls EndGameManager.SetEverythingUp. /// @@ -50,12 +59,6 @@ public abstract class CustomGameOver /// Type of the custom game over. public static void Trigger(IEnumerable winners) where T : CustomGameOver { - if (!AmongUsClient.Instance.AmHost) - { - Logger.Error("Only the host can send a custom game over."); - return; - } - var reason = GameOverManager.GetGameOverId(); var data = new GameOverData(reason, [.. winners]); diff --git a/MiraAPI/Networking/CustomGameOverRpc.cs b/MiraAPI/Networking/CustomGameOverRpc.cs index a2419f0..61d1f63 100644 --- a/MiraAPI/Networking/CustomGameOverRpc.cs +++ b/MiraAPI/Networking/CustomGameOverRpc.cs @@ -48,11 +48,17 @@ public class CustomGameOverRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc< { if (GameOverManager.TryGetGameOver(data.Reason, out var gameOver)) { + if (!gameOver!.VerifyCondition()) + { + Logger.Info($"Game over condition not met for {gameOver.GetType().Name}"); + return; + } + CustomGameOver.Instance = gameOver; if (AmongUsClient.Instance.AmHost) { - GameManager.Instance.RpcEndGame(gameOver!, false); + GameManager.Instance.RpcEndGame(gameOver, false); } } else