mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
allow any player to trigger gameover, but add verification
This commit is contained in:
1 parent
3387564f2d
commit
3d91c8de25
2 files changed
+16
-7
No files matched your search
@@ -15,6 +15,15 @@ public abstract class CustomGameOver
|
||||
/// </summary>
|
||||
public static CustomGameOver? Instance { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Verifies if the condition for this CustomGameOver is met.
|
||||
/// </summary>
|
||||
/// <returns>True if the condition is met, otherwise false.</returns>
|
||||
public virtual bool VerifyCondition()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs before the base game calls EndGameManager.SetEverythingUp.
|
||||
/// </summary>
|
||||
@@ -50,12 +59,6 @@ public abstract class CustomGameOver
|
||||
/// <typeparam name="T">Type of the custom game over.</typeparam>
|
||||
public static void Trigger<T>(IEnumerable<NetworkedPlayerInfo> winners) where T : CustomGameOver
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost)
|
||||
{
|
||||
Logger<MiraApiPlugin>.Error("Only the host can send a custom game over.");
|
||||
return;
|
||||
}
|
||||
|
||||
var reason = GameOverManager.GetGameOverId<T>();
|
||||
var data = new GameOverData(reason, [.. winners]);
|
||||
|
||||
|
||||
@@ -48,11 +48,17 @@ public class CustomGameOverRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<
|
||||
{
|
||||
if (GameOverManager.TryGetGameOver(data.Reason, out var gameOver))
|
||||
{
|
||||
if (!gameOver!.VerifyCondition())
|
||||
{
|
||||
Logger<MiraApiPlugin>.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
|
||||
|
||||
Reference in new issue
Block a user