diff --git a/MiraAPI/Events/Vanilla/Gameplay/AfterMurderEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/AfterMurderEvent.cs index fcf9df4..0f0da3b 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/AfterMurderEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/AfterMurderEvent.cs @@ -15,14 +15,21 @@ public class AfterMurderEvent : MiraEvent /// public PlayerControl Target { get; } + /// + /// Gets the player's body, if it exists. + /// + public DeadBody? DeadBody { get; } + /// /// Initializes a new instance of the class. /// /// The killer. /// The killed player. - public AfterMurderEvent(PlayerControl source, PlayerControl target) + /// The player's vody, if it exists. + public AfterMurderEvent(PlayerControl source, PlayerControl target, DeadBody? deadBody) { Source = source; Target = target; + DeadBody = deadBody; } } diff --git a/MiraAPI/Events/Vanilla/Player/PlayerDeathEvent.cs b/MiraAPI/Events/Vanilla/Player/PlayerDeathEvent.cs index e787b13..9b1ae49 100644 --- a/MiraAPI/Events/Vanilla/Player/PlayerDeathEvent.cs +++ b/MiraAPI/Events/Vanilla/Player/PlayerDeathEvent.cs @@ -15,14 +15,21 @@ public class PlayerDeathEvent : MiraEvent /// public DeathReason DeathReason { get; } + /// + /// Gets the dead body associated with the player, if any. + /// + public DeadBody? DeadBody { get; } + /// /// Initializes a new instance of the class. /// /// The player who died. /// The reason the player died. - public PlayerDeathEvent(PlayerControl player, DeathReason reason) + /// The player's body, if it exists. + public PlayerDeathEvent(PlayerControl player, DeathReason reason, DeadBody? deadBody) { Player = player; DeathReason = reason; + DeadBody = deadBody; } } diff --git a/MiraAPI/Networking/CustomMurderRpc.cs b/MiraAPI/Networking/CustomMurderRpc.cs index 5879ebf..4a7bc30 100644 --- a/MiraAPI/Networking/CustomMurderRpc.cs +++ b/MiraAPI/Networking/CustomMurderRpc.cs @@ -264,7 +264,7 @@ public static class CustomMurderRpc deadBody.enabled = true; } - var afterMurderEvent = new AfterMurderEvent(source, target); + var afterMurderEvent = new AfterMurderEvent(source, target, deadBody); MiraEventManager.InvokeEvent(afterMurderEvent); if (!isParticipant) diff --git a/MiraAPI/Patches/Events/KillAnimationPatches.cs b/MiraAPI/Patches/Events/KillAnimationPatches.cs index 3572ff8..5e7b3ef 100644 --- a/MiraAPI/Patches/Events/KillAnimationPatches.cs +++ b/MiraAPI/Patches/Events/KillAnimationPatches.cs @@ -1,6 +1,7 @@ using HarmonyLib; using MiraAPI.Events; using MiraAPI.Events.Vanilla.Gameplay; +using MiraAPI.Utilities; namespace MiraAPI.Patches.Events; @@ -19,7 +20,7 @@ public static class KillAnimationPatches [HarmonyPatch(typeof(KillAnimation), nameof(KillAnimation.CoPerformKill))] public static void KillAnimPostfix(PlayerControl source, PlayerControl target) { - var afterMurderEvent = new AfterMurderEvent(source, target); + var afterMurderEvent = new AfterMurderEvent(source, target, Helpers.GetBodyById(target.PlayerId)); MiraEventManager.InvokeEvent(afterMurderEvent); } } diff --git a/MiraAPI/Patches/PlayerControlPatches.cs b/MiraAPI/Patches/PlayerControlPatches.cs index 0f53f9f..ef702b2 100644 --- a/MiraAPI/Patches/PlayerControlPatches.cs +++ b/MiraAPI/Patches/PlayerControlPatches.cs @@ -6,6 +6,7 @@ using MiraAPI.Events.Vanilla.Player; using MiraAPI.Hud; using MiraAPI.Modifiers; using MiraAPI.Roles; +using MiraAPI.Utilities; using MiraAPI.Voting; using Reactor.Utilities.Extensions; @@ -41,7 +42,7 @@ internal static class PlayerControlPatches // ReSharper disable once InconsistentNaming public static void PlayerControlDiePostfix(PlayerControl __instance, DeathReason reason) { - var deathEvent = new PlayerDeathEvent(__instance, reason); + var deathEvent = new PlayerDeathEvent(__instance, reason, Helpers.GetBodyById(__instance.PlayerId)); MiraEventManager.InvokeEvent(deathEvent); var modifiersComponent = __instance.GetComponent();