From 31132e6e657ab5e1b8a9aa0bf5908d883369b672 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Sat, 29 Mar 2025 21:51:31 -0400 Subject: [PATCH] add RoundStartEvent.cs --- .../Vanilla/Gameplay/RoundStartEvent.cs | 21 +++++++++++++++++++ MiraAPI/Patches/IntroCutscenePatches.cs | 1 + MiraAPI/Patches/Roles/EjectionPatches.cs | 9 ++++++++ 3 files changed, 31 insertions(+) create mode 100644 MiraAPI/Events/Vanilla/Gameplay/RoundStartEvent.cs diff --git a/MiraAPI/Events/Vanilla/Gameplay/RoundStartEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/RoundStartEvent.cs new file mode 100644 index 0000000..a50fde5 --- /dev/null +++ b/MiraAPI/Events/Vanilla/Gameplay/RoundStartEvent.cs @@ -0,0 +1,21 @@ +namespace MiraAPI.Events.Vanilla.Gameplay; + +/// +/// Start Round event, invoked on IntroCutscene.OnDestroy and ExileController.WrapUp. +/// +public class RoundStartEvent : MiraEvent +{ + /// + /// Gets a value indicating whether the event was triggered by the IntroCutscene or ExileController. + /// + public bool TriggeredByIntro { get; } + + /// + /// Initializes a new instance of the class. + /// + /// Whether the event was triggered by the intro or not. + public RoundStartEvent(bool triggeredByIntro) + { + TriggeredByIntro = triggeredByIntro; + } +} diff --git a/MiraAPI/Patches/IntroCutscenePatches.cs b/MiraAPI/Patches/IntroCutscenePatches.cs index 28c576f..d068f26 100644 --- a/MiraAPI/Patches/IntroCutscenePatches.cs +++ b/MiraAPI/Patches/IntroCutscenePatches.cs @@ -61,5 +61,6 @@ public static class IntroCutscenePatches public static void GameBeginPatch(IntroCutscene __instance) { MiraEventManager.InvokeEvent(new IntroEndEvent(__instance)); + MiraEventManager.InvokeEvent(new RoundStartEvent(true)); } } diff --git a/MiraAPI/Patches/Roles/EjectionPatches.cs b/MiraAPI/Patches/Roles/EjectionPatches.cs index 48d6abb..be8ef41 100644 --- a/MiraAPI/Patches/Roles/EjectionPatches.cs +++ b/MiraAPI/Patches/Roles/EjectionPatches.cs @@ -1,5 +1,6 @@ using HarmonyLib; using MiraAPI.Events; +using MiraAPI.Events.Vanilla.Gameplay; using MiraAPI.Events.Vanilla.Meeting; using MiraAPI.Roles; @@ -31,4 +32,12 @@ public static class EjectionPatches __instance.completeString = role.GetCustomEjectionMessage(__instance.initData.networkedPlayer); } + + [HarmonyPostfix] + [HarmonyPatch(nameof(ExileController.WrapUp))] + public static void WrapUpPostfix(ExileController __instance) + { + var @event = new RoundStartEvent(false); + MiraEventManager.InvokeEvent(@event); + } }