From 870c913b5d410e6f96dab89e099ed13b6928c419 Mon Sep 17 00:00:00 2001
From: XtraCube <72575280+XtraCube@users.noreply.github.com>
Date: Sun, 8 Dec 2024 15:36:41 -0500
Subject: [PATCH] update to handle emergency meeting
---
...portDeadBodyEvent.cs => StartMeetingEvent.cs} | 16 ++++++++--------
...dyEventPatch.cs => StartMeetingEventPatch.cs} | 8 ++++----
2 files changed, 12 insertions(+), 12 deletions(-)
rename MiraAPI/Events/Vanilla/{ReportDeadBodyEvent.cs => StartMeetingEvent.cs} (51%)
rename MiraAPI/Patches/Events/{ReportDeadBodyEventPatch.cs => StartMeetingEventPatch.cs} (62%)
diff --git a/MiraAPI/Events/Vanilla/ReportDeadBodyEvent.cs b/MiraAPI/Events/Vanilla/StartMeetingEvent.cs
similarity index 51%
rename from MiraAPI/Events/Vanilla/ReportDeadBodyEvent.cs
rename to MiraAPI/Events/Vanilla/StartMeetingEvent.cs
index c5c0648..2e3d8c2 100644
--- a/MiraAPI/Events/Vanilla/ReportDeadBodyEvent.cs
+++ b/MiraAPI/Events/Vanilla/StartMeetingEvent.cs
@@ -1,32 +1,32 @@
namespace MiraAPI.Events.Vanilla;
///
-/// The event that is invoked when a player reports a dead body.
+/// The event that is invoked when a meeting is called
///
-public class ReportDeadBodyEvent : MiraCancelableEvent
+public class StartMeetingEvent : MiraCancelableEvent
{
///
- /// Gets the player that is reporting the body.
+ /// Gets the player that is calling the meeting.
///
public PlayerControl Reporter { get; }
///
- /// Gets the player that is being reported.
+ /// Gets the player that is being reported. Will be null for emergency meeting.
///
- public NetworkedPlayerInfo Target { get; }
+ public NetworkedPlayerInfo? Target { get; }
///
- /// Gets the body that is being reported.
+ /// Gets the body that is being reported. Will be null for emergency meeting.
///
public DeadBody? Body { get; }
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The player who reported the body.
/// The player being reported.
/// The body being reported.
- public ReportDeadBodyEvent(PlayerControl reporter, NetworkedPlayerInfo target, DeadBody? body)
+ public StartMeetingEvent(PlayerControl reporter, NetworkedPlayerInfo? target, DeadBody? body)
{
Reporter = reporter;
Target = target;
diff --git a/MiraAPI/Patches/Events/ReportDeadBodyEventPatch.cs b/MiraAPI/Patches/Events/StartMeetingEventPatch.cs
similarity index 62%
rename from MiraAPI/Patches/Events/ReportDeadBodyEventPatch.cs
rename to MiraAPI/Patches/Events/StartMeetingEventPatch.cs
index 8e53eab..f818363 100644
--- a/MiraAPI/Patches/Events/ReportDeadBodyEventPatch.cs
+++ b/MiraAPI/Patches/Events/StartMeetingEventPatch.cs
@@ -6,14 +6,14 @@ using MiraAPI.Utilities;
namespace MiraAPI.Patches.Events;
[HarmonyPatch]
-public static class ReportDeadBodyEventPatch
+public static class StartMeetingEventPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.ReportDeadBody))]
- public static bool PlayerControlReportDeadBodyPrefix(PlayerControl __instance, NetworkedPlayerInfo target)
+ public static bool PlayerControlReportDeadBodyPrefix(PlayerControl __instance, NetworkedPlayerInfo? target)
{
- var body = Helpers.GetBodyById(target.PlayerId);
- var @event = new ReportDeadBodyEvent(__instance, target, body);
+ var body = target != null ? Helpers.GetBodyById(target.PlayerId) : null;
+ var @event = new StartMeetingEvent(__instance, target, body);
MiraEventManager.InvokeEvent(@event);
return !@event.IsCancelled;
}