update to handle emergency meeting

This commit is contained in:
XtraCube committed 2024-12-08 15:36:41 -05:00
1 parent c1d2455e4d
commit 870c913b5d
2 files changed
+12 -12

No files matched your search

@@ -1,32 +1,32 @@
namespace MiraAPI.Events.Vanilla;
/// <summary>
/// The event that is invoked when a player reports a dead body.
/// The event that is invoked when a meeting is called
/// </summary>
public class ReportDeadBodyEvent : MiraCancelableEvent
public class StartMeetingEvent : MiraCancelableEvent
{
/// <summary>
/// Gets the player that is reporting the body.
/// Gets the player that is calling the meeting.
/// </summary>
public PlayerControl Reporter { get; }
/// <summary>
/// Gets the player that is being reported.
/// Gets the player that is being reported. Will be null for emergency meeting.
/// </summary>
public NetworkedPlayerInfo Target { get; }
public NetworkedPlayerInfo? Target { get; }
/// <summary>
/// Gets the body that is being reported.
/// Gets the body that is being reported. Will be null for emergency meeting.
/// </summary>
public DeadBody? Body { get; }
/// <summary>
/// Initializes a new instance of the <see cref="ReportDeadBodyEvent"/> class.
/// Initializes a new instance of the <see cref="StartMeetingEvent"/> class.
/// </summary>
/// <param name="reporter">The player who reported the body.</param>
/// <param name="target">The player being reported.</param>
/// <param name="body">The body being reported.</param>
public ReportDeadBodyEvent(PlayerControl reporter, NetworkedPlayerInfo target, DeadBody? body)
public StartMeetingEvent(PlayerControl reporter, NetworkedPlayerInfo? target, DeadBody? body)
{
Reporter = reporter;
Target = target;
@@ -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;
}