mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
improved report body event and added vent events
This commit is contained in:
1 parent
2567722b52
commit
29c2939871
7 files changed
+139
-30
No files matched your search
@@ -0,0 +1,28 @@
|
||||
namespace MiraAPI.Events.Vanilla;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is invoked when a player enters a vent. This event is cancelable.
|
||||
/// </summary>
|
||||
public class EnterVentEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the player that is entering the vent.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vent that the player is entering.
|
||||
/// </summary>
|
||||
public Vent Vent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EnterVentEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="player">The player that is entering the vent.</param>
|
||||
/// <param name="vent">The vent being entered.</param>
|
||||
public EnterVentEvent(PlayerControl player, Vent vent)
|
||||
{
|
||||
Player = player;
|
||||
Vent = vent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace MiraAPI.Events.Vanilla;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is invoked when a player exits a vent. This event is cancelable.
|
||||
/// </summary>
|
||||
public class ExitVentEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the player that is exiting the vent.
|
||||
/// </summary>
|
||||
public PlayerControl Player { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vent that the player is exiting.
|
||||
/// </summary>
|
||||
public Vent Vent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ExitVentEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="player">The player who is exiting the vent.</param>
|
||||
/// <param name="vent">The vent being exited from.</param>
|
||||
public ExitVentEvent(PlayerControl player, Vent vent)
|
||||
{
|
||||
Player = player;
|
||||
Vent = vent;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
namespace MiraAPI.Events.Vanilla;
|
||||
|
||||
/// <summary>
|
||||
/// Button click event for <see cref="ReportButton"/> from Vanilla Among Us.
|
||||
/// </summary>
|
||||
public class ReportButtonClickEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the instance of <see cref="ReportButton"/> that was clicked.
|
||||
/// </summary>
|
||||
public ReportButton Button { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReportButtonClickEvent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="button">The ReportButton.</param>
|
||||
public ReportButtonClickEvent(ReportButton button)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace MiraAPI.Events.Vanilla;
|
||||
|
||||
/// <summary>
|
||||
/// The event that is invoked when a player reports a dead body.
|
||||
/// </summary>
|
||||
public class ReportDeadBodyEvent : MiraCancelableEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the player that is reporting the body.
|
||||
/// </summary>
|
||||
public PlayerControl Reporter { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the player that is being reported.
|
||||
/// </summary>
|
||||
public NetworkedPlayerInfo Target { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the body that is being reported.
|
||||
/// </summary>
|
||||
public DeadBody? Body { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReportDeadBodyEvent"/> 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)
|
||||
{
|
||||
Reporter = reporter;
|
||||
Target = target;
|
||||
Body = body;
|
||||
}
|
||||
}
|
||||
@@ -19,15 +19,6 @@ public static class HudButtonEventPatches
|
||||
return !@event.IsCancelled;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ReportButton), nameof(ReportButton.DoClick))]
|
||||
public static bool ReportButtonDoClickPrefix(ReportButton __instance)
|
||||
{
|
||||
var @event = new ReportButtonClickEvent(__instance);
|
||||
MiraEventManager.InvokeEvent(@event);
|
||||
return !@event.IsCancelled;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(SabotageButton), nameof(SabotageButton.DoClick))]
|
||||
public static bool SabotageButtonDoClickPrefix(SabotageButton __instance)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using HarmonyLib;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Vanilla;
|
||||
using MiraAPI.Utilities;
|
||||
|
||||
namespace MiraAPI.Patches.Events;
|
||||
|
||||
[HarmonyPatch]
|
||||
public static class ReportDeadBodyEventPatch
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.ReportDeadBody))]
|
||||
public static bool PlayerControlReportDeadBodyPrefix(PlayerControl __instance, NetworkedPlayerInfo target)
|
||||
{
|
||||
var body = Helpers.GetBodyById(target.PlayerId);
|
||||
var @event = new ReportDeadBodyEvent(__instance, target, body);
|
||||
MiraEventManager.InvokeEvent(@event);
|
||||
return !@event.IsCancelled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using HarmonyLib;
|
||||
using MiraAPI.Events;
|
||||
using MiraAPI.Events.Vanilla;
|
||||
|
||||
namespace MiraAPI.Patches.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Patches to invoke vent related MiraEvents.
|
||||
/// </summary>
|
||||
[HarmonyPatch]
|
||||
public static class VentEventPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(Vent), nameof(Vent.EnterVent))]
|
||||
public static void EnterVentPrefix(Vent __instance, PlayerControl pc)
|
||||
{
|
||||
var @event = new EnterVentEvent(pc, __instance);
|
||||
MiraEventManager.InvokeEvent(@event);
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(Vent), nameof(Vent.ExitVent))]
|
||||
public static void ExitVentPrefix(Vent __instance, PlayerControl pc)
|
||||
{
|
||||
var @event = new ExitVentEvent(pc, __instance);
|
||||
MiraEventManager.InvokeEvent(@event);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user