From c953b53c36b93fcf359a85f3616cc56521421a7d Mon Sep 17 00:00:00 2001
From: Mike <146554836+MikeSus1@users.noreply.github.com>
Date: Wed, 26 Mar 2025 18:32:34 +0100
Subject: [PATCH 01/15] feat: Add MicroHID exploding event
---
.../Player/ExplodingMicroHidEventArgs.cs | 49 +++++++++++++++++++
EXILED/Exiled.Events/Handlers/Player.cs | 11 +++++
.../Events/Player/ExplodingMicroHid.cs | 40 +++++++++++++++
3 files changed, 100 insertions(+)
create mode 100644 EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs
create mode 100644 EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
diff --git a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs
new file mode 100644
index 0000000000..3bda955888
--- /dev/null
+++ b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs
@@ -0,0 +1,49 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (c) ExMod Team. All rights reserved.
+// Licensed under the CC BY-SA 3.0 license.
+//
+// -----------------------------------------------------------------------
+
+namespace Exiled.Events.EventArgs.Player
+{
+ using Exiled.API.Features.Items;
+ using Exiled.Events.EventArgs.Interfaces;
+
+ ///
+ /// Contains all information before the micro hid explode.
+ ///
+ public class ExplodingMicroHidEventArgs : IPlayerEvent
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ public ExplodingMicroHidEventArgs(Item item)
+ {
+ Item = item;
+ MicroHid = item as MicroHid;
+ Player = item.Owner;
+ }
+
+ ///
+ /// Gets the item.
+ ///
+ public Item Item { get; }
+
+ ///
+ /// Gets the player in owner of the item.
+ ///
+ public Exiled.API.Features.Player Player { get; }
+
+ ///
+ /// Gets Scp1344 item.
+ ///
+ public MicroHid MicroHid { get; }
+
+ ///
+ /// Gets or sets a value indicating whether the player can explode the micro HID.
+ ///
+ public bool IsAllowed { get; set; } = true;
+ }
+}
\ No newline at end of file
diff --git a/EXILED/Exiled.Events/Handlers/Player.cs b/EXILED/Exiled.Events/Handlers/Player.cs
index ac58bb3085..09e574fa4d 100644
--- a/EXILED/Exiled.Events/Handlers/Player.cs
+++ b/EXILED/Exiled.Events/Handlers/Player.cs
@@ -583,6 +583,11 @@ public class Player
///
public static Event ChangingDisruptorMode { get; set; } = new();
+ ///
+ /// Invoked before the player explode with the micro HID.
+ ///
+ public static Event ExplodingMicroHid { get; set; } = new();
+
///
/// Invoked before player interacts with coffee cup.
///
@@ -1260,6 +1265,12 @@ public static void OnItemRemoved(ReferenceHub referenceHub, InventorySystem.Item
/// The instance.
public static void OnChangingDisruptorMode(ChangingDisruptorModeEventArgs ev) => ChangingDisruptorMode.InvokeSafely(ev);
+ ///
+ /// Called before disruptor's mode is changed.
+ ///
+ /// The instance.
+ public static void OnExplodingMicroHid(ExplodingMicroHidEventArgs ev) => ExplodingMicroHid.InvokeSafely(ev);
+
///
/// Called before player interacts with coffee cup.
///
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
new file mode 100644
index 0000000000..4edba59f7f
--- /dev/null
+++ b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
@@ -0,0 +1,40 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (c) ExMod Team. All rights reserved.
+// Licensed under the CC BY-SA 3.0 license.
+//
+// -----------------------------------------------------------------------
+
+#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
+
+namespace Exiled.Events.Patches.Events.Player
+{
+ using Exiled.API.Features;
+ using Exiled.API.Features.Items;
+ using Exiled.Events.Attributes;
+ using Exiled.Events.EventArgs.Player;
+ using HarmonyLib;
+ using InventorySystem.Items.MicroHID;
+
+ ///
+ /// Patches .
+ /// Adds the event.
+ ///
+ [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.ExplodingMicroHid))]
+ [HarmonyPatch(typeof(InventorySystem.Items.MicroHID.Modules.ChargeFireModeModule), nameof(InventorySystem.Items.MicroHID.Modules.ChargeFireModeModule.ServerExplode))]
+ internal static class ExplodingMicroHid
+ {
+ private static bool Prefix(ref MicroHIDItem __instance)
+ {
+ ExplodingMicroHidEventArgs ev = new(Item.Get(__instance));
+ Exiled.Events.Handlers.Player.OnExplodingMicroHid(ev);
+
+ if (!ev.IsAllowed)
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
From 28de3b2b87579aa4f34191ec2dcae7b3ef0ee1b2 Mon Sep 17 00:00:00 2001
From: Mike <146554836+MikeSus1@users.noreply.github.com>
Date: Wed, 26 Mar 2025 19:12:53 +0100
Subject: [PATCH 02/15] actual method now
---
.../Events/Player/ExplodingMicroHid.cs | 65 +++++++++++++++++--
1 file changed, 58 insertions(+), 7 deletions(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
index 4edba59f7f..e485743991 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
@@ -9,24 +9,39 @@
namespace Exiled.Events.Patches.Events.Player
{
- using Exiled.API.Features;
- using Exiled.API.Features.Items;
- using Exiled.Events.Attributes;
+ using Attributes;
+
using Exiled.Events.EventArgs.Player;
+
+ using Footprinting;
using HarmonyLib;
- using InventorySystem.Items.MicroHID;
+
+ using Interactables;
+ using Interactables.Interobjects.DoorUtils;
+ using InventorySystem.Items.MicroHID.Modules;
+ using MapGeneration;
+
+ using PlayerRoles.FirstPersonControl;
+ using PlayerStatsSystem;
+
+ using UnityEngine;
///
/// Patches .
/// Adds the event.
///
[EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.ExplodingMicroHid))]
- [HarmonyPatch(typeof(InventorySystem.Items.MicroHID.Modules.ChargeFireModeModule), nameof(InventorySystem.Items.MicroHID.Modules.ChargeFireModeModule.ServerExplode))]
+ [HarmonyPatch(typeof(ChargeFireModeModule), nameof(ChargeFireModeModule.ServerExplode))]
internal static class ExplodingMicroHid
{
- private static bool Prefix(ref MicroHIDItem __instance)
+ private static bool Prefix(ref ChargeFireModeModule __instance)
{
- ExplodingMicroHidEventArgs ev = new(Item.Get(__instance));
+ if (__instance._alreadyExploded)
+ {
+ return false;
+ }
+
+ ExplodingMicroHidEventArgs ev = new(API.Features.Items.Item.Get(__instance.MicroHid));
Exiled.Events.Handlers.Player.OnExplodingMicroHid(ev);
if (!ev.IsAllowed)
@@ -34,6 +49,42 @@ private static bool Prefix(ref MicroHIDItem __instance)
return false;
}
+ __instance._alreadyExploded = true;
+ __instance.MicroHid.BrokenSync.ServerSetBroken();
+ ReferenceHub owner = __instance.Item.Owner;
+ IFpcRole fpcRole = owner.roleManager.CurrentRole as IFpcRole;
+ if (fpcRole == null)
+ {
+ return false;
+ }
+
+ __instance.Energy -= 0.25f;
+ Vector3 position = fpcRole.FpcModule.Position;
+ int num;
+ HitregUtils.OverlapSphere(position, 10f, out num, null);
+ for (int i = 0; i < num; i++)
+ {
+ InteractableCollider interactableCollider;
+ if (HitregUtils.DetectionsNonAlloc[i].TryGetComponent(out interactableCollider))
+ {
+ IDamageableDoor damageableDoor = interactableCollider.Target as IDamageableDoor;
+ if (damageableDoor != null && __instance.CheckIntercolLineOfSight(position, interactableCollider))
+ {
+ damageableDoor.ServerDamage(350f, DoorDamageType.Grenade, new Footprint(owner));
+ }
+ }
+ }
+
+ RoomIdentifier roomIdentifier = RoomIdUtils.RoomAtPositionRaycasts(position, true);
+ foreach (RoomLightController roomLightController in RoomLightController.Instances)
+ {
+ if (!(roomLightController.Room != roomIdentifier) && roomLightController.LightsEnabled)
+ {
+ roomLightController.ServerFlickerLights(1f);
+ }
+ }
+
+ owner.playerStats.DealDamage(new MicroHidDamageHandler(125f, __instance.MicroHid));
return true;
}
}
From 4846e24ffd50ac626925826f0633bfc312c19cf0 Mon Sep 17 00:00:00 2001
From: Yamato
Date: Thu, 27 Mar 2025 00:08:24 +0100
Subject: [PATCH 03/15] fix naming & add new interface
- MicroHid is renamed to MicroHID
- IMicroHIDEvent is added
---
.../EventArgs/Interfaces/IMicroHIDEvent.cs | 22 +++++++++++++++++++
.../Player/ChangingMicroHIDStateEventArgs.cs | 2 +-
.../Player/ExplodingMicroHidEventArgs.cs | 20 ++++++++---------
.../Player/UsingMicroHIDEnergyEventArgs.cs | 2 +-
EXILED/Exiled.Events/Handlers/Player.cs | 6 ++---
.../Events/Player/ExplodingMicroHid.cs | 8 +++----
6 files changed, 41 insertions(+), 19 deletions(-)
create mode 100644 EXILED/Exiled.Events/EventArgs/Interfaces/IMicroHIDEvent.cs
diff --git a/EXILED/Exiled.Events/EventArgs/Interfaces/IMicroHIDEvent.cs b/EXILED/Exiled.Events/EventArgs/Interfaces/IMicroHIDEvent.cs
new file mode 100644
index 0000000000..50112dead0
--- /dev/null
+++ b/EXILED/Exiled.Events/EventArgs/Interfaces/IMicroHIDEvent.cs
@@ -0,0 +1,22 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (c) ExMod Team. All rights reserved.
+// Licensed under the CC BY-SA 3.0 license.
+//
+// -----------------------------------------------------------------------
+
+namespace Exiled.Events.EventArgs.Interfaces
+{
+ using API.Features.Items;
+
+ ///
+ /// Event args used for all related events.
+ ///
+ public interface IMicroHIDEvent : IItemEvent
+ {
+ ///
+ /// Gets the triggering the event.
+ ///
+ public MicroHid MicroHID { get; }
+ }
+}
\ No newline at end of file
diff --git a/EXILED/Exiled.Events/EventArgs/Player/ChangingMicroHIDStateEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ChangingMicroHIDStateEventArgs.cs
index 2881241cdd..3e3c1eee9c 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/ChangingMicroHIDStateEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/ChangingMicroHIDStateEventArgs.cs
@@ -20,7 +20,7 @@ namespace Exiled.Events.EventArgs.Player
///
/// Contains all information before MicroHID state is changed.
///
- public class ChangingMicroHIDStateEventArgs : IDeniableEvent, IItemEvent
+ public class ChangingMicroHIDStateEventArgs : IDeniableEvent, IMicroHIDEvent
{
///
/// Initializes a new instance of the class.
diff --git a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs
index 3bda955888..5799d4ec8e 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------
+// -----------------------------------------------------------------------
//
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
@@ -9,27 +9,27 @@ namespace Exiled.Events.EventArgs.Player
{
using Exiled.API.Features.Items;
using Exiled.Events.EventArgs.Interfaces;
+ using InventorySystem.Items.MicroHID;
///
/// Contains all information before the micro hid explode.
///
- public class ExplodingMicroHidEventArgs : IPlayerEvent
+ public class ExplodingMicroHIDEventArgs : IPlayerEvent, IMicroHIDEvent
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
///
- public ExplodingMicroHidEventArgs(Item item)
+ public ExplodingMicroHIDEventArgs(MicroHIDItem item)
{
- Item = item;
- MicroHid = item as MicroHid;
- Player = item.Owner;
+ MicroHID = Item.Get(item);
+ Player = MicroHID.Owner;
}
///
/// Gets the item.
///
- public Item Item { get; }
+ public Item Item => MicroHID;
///
/// Gets the player in owner of the item.
@@ -37,9 +37,9 @@ public ExplodingMicroHidEventArgs(Item item)
public Exiled.API.Features.Player Player { get; }
///
- /// Gets Scp1344 item.
+ /// Gets MicroHid item.
///
- public MicroHid MicroHid { get; }
+ public MicroHid MicroHID { get; }
///
/// Gets or sets a value indicating whether the player can explode the micro HID.
diff --git a/EXILED/Exiled.Events/EventArgs/Player/UsingMicroHIDEnergyEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/UsingMicroHIDEnergyEventArgs.cs
index cbf292d86f..2cfe7fee35 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/UsingMicroHIDEnergyEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/UsingMicroHIDEnergyEventArgs.cs
@@ -17,7 +17,7 @@ namespace Exiled.Events.EventArgs.Player
///
/// Contains all information before MicroHID energy is changed.
///
- public class UsingMicroHIDEnergyEventArgs : IDeniableEvent, IItemEvent
+ public class UsingMicroHIDEnergyEventArgs : IDeniableEvent, IMicroHIDEvent
{
///
/// Initializes a new instance of the class.
diff --git a/EXILED/Exiled.Events/Handlers/Player.cs b/EXILED/Exiled.Events/Handlers/Player.cs
index 09e574fa4d..5b7916ef84 100644
--- a/EXILED/Exiled.Events/Handlers/Player.cs
+++ b/EXILED/Exiled.Events/Handlers/Player.cs
@@ -586,7 +586,7 @@ public class Player
///
/// Invoked before the player explode with the micro HID.
///
- public static Event ExplodingMicroHid { get; set; } = new();
+ public static Event ExplodingMicroHID { get; set; } = new();
///
/// Invoked before player interacts with coffee cup.
@@ -1268,8 +1268,8 @@ public static void OnItemRemoved(ReferenceHub referenceHub, InventorySystem.Item
///
/// Called before disruptor's mode is changed.
///
- /// The instance.
- public static void OnExplodingMicroHid(ExplodingMicroHidEventArgs ev) => ExplodingMicroHid.InvokeSafely(ev);
+ /// The instance.
+ public static void OnExplodingMicroHID(ExplodingMicroHIDEventArgs ev) => ExplodingMicroHID.InvokeSafely(ev);
///
/// Called before player interacts with coffee cup.
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
index e485743991..a7dc968def 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
@@ -1,4 +1,4 @@
-// -----------------------------------------------------------------------
+// -----------------------------------------------------------------------
//
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
@@ -30,7 +30,7 @@ namespace Exiled.Events.Patches.Events.Player
/// Patches .
/// Adds the event.
///
- [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.ExplodingMicroHid))]
+ [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.ExplodingMicroHID))]
[HarmonyPatch(typeof(ChargeFireModeModule), nameof(ChargeFireModeModule.ServerExplode))]
internal static class ExplodingMicroHid
{
@@ -41,8 +41,8 @@ private static bool Prefix(ref ChargeFireModeModule __instance)
return false;
}
- ExplodingMicroHidEventArgs ev = new(API.Features.Items.Item.Get(__instance.MicroHid));
- Exiled.Events.Handlers.Player.OnExplodingMicroHid(ev);
+ ExplodingMicroHIDEventArgs ev = new(__instance.MicroHid);
+ Exiled.Events.Handlers.Player.OnExplodingMicroHID(ev);
if (!ev.IsAllowed)
{
From c74ed5913bff3ab20a3023ba5c0f95f1978828b8 Mon Sep 17 00:00:00 2001
From: Yamato
Date: Thu, 27 Mar 2025 00:11:01 +0100
Subject: [PATCH 04/15] Fix build error
---
EXILED/Exiled.Events/EventArgs/Interfaces/IMicroHIDEvent.cs | 2 +-
.../EventArgs/Player/ExplodingMicroHidEventArgs.cs | 2 +-
.../Exiled.Events/Patches/Events/Player/UsingMicroHIDEnergy.cs | 3 ---
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/EXILED/Exiled.Events/EventArgs/Interfaces/IMicroHIDEvent.cs b/EXILED/Exiled.Events/EventArgs/Interfaces/IMicroHIDEvent.cs
index 50112dead0..bc17988cc2 100644
--- a/EXILED/Exiled.Events/EventArgs/Interfaces/IMicroHIDEvent.cs
+++ b/EXILED/Exiled.Events/EventArgs/Interfaces/IMicroHIDEvent.cs
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
-//
+//
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
//
diff --git a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs
index 5799d4ec8e..647ee67579 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
-//
+//
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
//
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/UsingMicroHIDEnergy.cs b/EXILED/Exiled.Events/Patches/Events/Player/UsingMicroHIDEnergy.cs
index 15634602db..115ffc8391 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/UsingMicroHIDEnergy.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/UsingMicroHIDEnergy.cs
@@ -10,14 +10,11 @@ namespace Exiled.Events.Patches.Events.Player
using System.Collections.Generic;
using System.Reflection.Emit;
- using API.Features;
using API.Features.Pools;
using Exiled.Events.Attributes;
using Exiled.Events.EventArgs.Player;
using HarmonyLib;
- using InventorySystem.Items.MicroHID;
using InventorySystem.Items.MicroHID.Modules;
- using UnityEngine;
using static HarmonyLib.AccessTools;
From 27a7e46a0d7b63d883abda47d9c3565a67b71966 Mon Sep 17 00:00:00 2001
From: Yamato
Date: Thu, 27 Mar 2025 00:12:04 +0100
Subject: [PATCH 05/15] wrong return anyways i will rewrite this patch into
transpiller
---
EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
index a7dc968def..493bdc764f 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
@@ -85,7 +85,7 @@ private static bool Prefix(ref ChargeFireModeModule __instance)
}
owner.playerStats.DealDamage(new MicroHidDamageHandler(125f, __instance.MicroHid));
- return true;
+ return false;
}
}
}
\ No newline at end of file
From c73b22f5bf48cb714896cbf3b630d8d55320c344 Mon Sep 17 00:00:00 2001
From: Mike <146554836+MikeSus1@users.noreply.github.com>
Date: Thu, 27 Mar 2025 10:30:41 +0100
Subject: [PATCH 06/15] fix build yamato
---
...xplodingMicroHidEventArgs.cs => ExplodingMicroHIDEventArgs.cs} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename EXILED/Exiled.Events/EventArgs/Player/{ExplodingMicroHidEventArgs.cs => ExplodingMicroHIDEventArgs.cs} (100%)
diff --git a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs
similarity index 100%
rename from EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHidEventArgs.cs
rename to EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs
From 28d0880daae80589b331da5a80aed039575d42fd Mon Sep 17 00:00:00 2001
From: Mike <146554836+MikeSus1@users.noreply.github.com>
Date: Thu, 27 Mar 2025 10:50:13 +0100
Subject: [PATCH 07/15] file header
---
.../EventArgs/Player/ExplodingMicroHIDEventArgs.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs
index 647ee67579..5799d4ec8e 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
-//
+//
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
//
From aae8c84e38ca7361cd4f37ae47a3546a8cc65960 Mon Sep 17 00:00:00 2001
From: Mike <146554836+MikeSus1@users.noreply.github.com>
Date: Thu, 27 Mar 2025 14:25:41 +0100
Subject: [PATCH 08/15] Is allowed fix
---
.../EventArgs/Player/ExplodingMicroHIDEventArgs.cs | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs
index 5799d4ec8e..75111f596b 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
-//
+//
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
//
@@ -14,16 +14,17 @@ namespace Exiled.Events.EventArgs.Player
///
/// Contains all information before the micro hid explode.
///
- public class ExplodingMicroHIDEventArgs : IPlayerEvent, IMicroHIDEvent
+ public class ExplodingMicroHIDEventArgs : IDeniableEvent, IMicroHIDEvent
{
///
/// Initializes a new instance of the class.
///
///
- public ExplodingMicroHIDEventArgs(MicroHIDItem item)
+ public ExplodingMicroHIDEventArgs(MicroHIDItem item, bool isAllowed = true)
{
MicroHID = Item.Get(item);
Player = MicroHID.Owner;
+ IsAllowed = isAllowed;
}
///
@@ -44,6 +45,6 @@ public ExplodingMicroHIDEventArgs(MicroHIDItem item)
///
/// Gets or sets a value indicating whether the player can explode the micro HID.
///
- public bool IsAllowed { get; set; } = true;
+ public bool IsAllowed { get; set; }
}
}
\ No newline at end of file
From ce1f57514af0abafd28fe1bc3d91d240c350bfef Mon Sep 17 00:00:00 2001
From: Mike <146554836+MikeSus1@users.noreply.github.com>
Date: Thu, 27 Mar 2025 14:31:35 +0100
Subject: [PATCH 09/15] xml fix
---
.../Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs
index 75111f596b..c2727317aa 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/ExplodingMicroHIDEventArgs.cs
@@ -20,6 +20,7 @@ public class ExplodingMicroHIDEventArgs : IDeniableEvent, IMicroHIDEvent
/// Initializes a new instance of the class.
///
///
+ /// Whether the Micro HID can explode the player or not.
public ExplodingMicroHIDEventArgs(MicroHIDItem item, bool isAllowed = true)
{
MicroHID = Item.Get(item);
From 6f5e3c512a5ccd83494c80c92a500c534d5e36d7 Mon Sep 17 00:00:00 2001
From: Yamato
Date: Mon, 31 Mar 2025 16:50:53 +0200
Subject: [PATCH 10/15] .
---
.../Events/Player/ExplodingMicroHid.cs | 51 +++++++++++++++++--
1 file changed, 46 insertions(+), 5 deletions(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
index 493bdc764f..c7762072b4 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
@@ -9,22 +9,22 @@
namespace Exiled.Events.Patches.Events.Player
{
- using Attributes;
+ using System.Collections.Generic;
+ using System.Reflection.Emit;
+ using Exiled.API.Features.Pools;
+ using Exiled.Events.Attributes;
using Exiled.Events.EventArgs.Player;
-
using Footprinting;
using HarmonyLib;
-
using Interactables;
using Interactables.Interobjects.DoorUtils;
using InventorySystem.Items.MicroHID.Modules;
using MapGeneration;
-
using PlayerRoles.FirstPersonControl;
using PlayerStatsSystem;
- using UnityEngine;
+ using static HarmonyLib.AccessTools;
///
/// Patches .
@@ -34,6 +34,47 @@ namespace Exiled.Events.Patches.Events.Player
[HarmonyPatch(typeof(ChargeFireModeModule), nameof(ChargeFireModeModule.ServerExplode))]
internal static class ExplodingMicroHid
{
+ private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
+ {
+ List newInstructions = ListPool.Pool.Get(instructions);
+
+ int offset = -2;
+ int index = newInstructions.FindIndex(x => x.StoresField(Field(typeof(ChargeFireModeModule), nameof(ChargeFireModeModule._alreadyExploded)))) + offset;
+
+ Label retLabel = generator.DefineLabel();
+
+ newInstructions[newInstructions.Count - 1].labels.Add(retLabel);
+
+ newInstructions.InsertRange(
+ index,
+ new[]
+ {
+ // this.MicroHid;
+ new CodeInstruction(OpCodes.Ldarg_0).MoveLabelsFrom(newInstructions[index]),
+ new(OpCodes.Call, PropertyGetter(typeof(ChargeFireModeModule), nameof(ChargeFireModeModule.MicroHid))),
+
+ // true
+ new(OpCodes.Ldc_I4_1),
+
+ // ExplodingMicroHIDEventArgs ev = new(MicroHIDItem, true);
+ new(OpCodes.Newobj, GetDeclaredConstructors(typeof(ExplodingMicroHIDEventArgs))[0]),
+ new(OpCodes.Dup),
+
+ // Handlers.Player.OnExplodingMicroHID(ev);
+ new(OpCodes.Call, Method(typeof(Handlers.Player), nameof(Handlers.Player.OnExplodingMicroHID))),
+
+ // if (!ev.IsAllowed)
+ // return;
+ new(OpCodes.Callvirt, PropertyGetter(typeof(ExplodingMicroHIDEventArgs), nameof(ExplodingMicroHIDEventArgs.IsAllowed))),
+ new(OpCodes.Brfalse_S, retLabel),
+ });
+
+ for (int z = 0; z < newInstructions.Count; z++)
+ yield return newInstructions[z];
+
+ ListPool.Pool.Return(newInstructions);
+ }
+
private static bool Prefix(ref ChargeFireModeModule __instance)
{
if (__instance._alreadyExploded)
From 7493e4b0d06fd9dc4f6f8cd6e90f3747fd733f8f Mon Sep 17 00:00:00 2001
From: Yamato
Date: Mon, 31 Mar 2025 16:51:06 +0200
Subject: [PATCH 11/15] Remove Prefix
---
.../Events/Player/ExplodingMicroHid.cs | 54 -------------------
1 file changed, 54 deletions(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
index c7762072b4..7a845b40dd 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
@@ -74,59 +74,5 @@ private static IEnumerable Transpiler(IEnumerable.Pool.Return(newInstructions);
}
-
- private static bool Prefix(ref ChargeFireModeModule __instance)
- {
- if (__instance._alreadyExploded)
- {
- return false;
- }
-
- ExplodingMicroHIDEventArgs ev = new(__instance.MicroHid);
- Exiled.Events.Handlers.Player.OnExplodingMicroHID(ev);
-
- if (!ev.IsAllowed)
- {
- return false;
- }
-
- __instance._alreadyExploded = true;
- __instance.MicroHid.BrokenSync.ServerSetBroken();
- ReferenceHub owner = __instance.Item.Owner;
- IFpcRole fpcRole = owner.roleManager.CurrentRole as IFpcRole;
- if (fpcRole == null)
- {
- return false;
- }
-
- __instance.Energy -= 0.25f;
- Vector3 position = fpcRole.FpcModule.Position;
- int num;
- HitregUtils.OverlapSphere(position, 10f, out num, null);
- for (int i = 0; i < num; i++)
- {
- InteractableCollider interactableCollider;
- if (HitregUtils.DetectionsNonAlloc[i].TryGetComponent(out interactableCollider))
- {
- IDamageableDoor damageableDoor = interactableCollider.Target as IDamageableDoor;
- if (damageableDoor != null && __instance.CheckIntercolLineOfSight(position, interactableCollider))
- {
- damageableDoor.ServerDamage(350f, DoorDamageType.Grenade, new Footprint(owner));
- }
- }
- }
-
- RoomIdentifier roomIdentifier = RoomIdUtils.RoomAtPositionRaycasts(position, true);
- foreach (RoomLightController roomLightController in RoomLightController.Instances)
- {
- if (!(roomLightController.Room != roomIdentifier) && roomLightController.LightsEnabled)
- {
- roomLightController.ServerFlickerLights(1f);
- }
- }
-
- owner.playerStats.DealDamage(new MicroHidDamageHandler(125f, __instance.MicroHid));
- return false;
- }
}
}
\ No newline at end of file
From d7ebbad41f6fa51d1d198db67f20a1790e5f0c9e Mon Sep 17 00:00:00 2001
From: Yamato
Date: Mon, 31 Mar 2025 16:51:34 +0200
Subject: [PATCH 12/15] remove uneeded using
---
.../Patches/Events/Player/ExplodingMicroHid.cs | 6 ------
1 file changed, 6 deletions(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
index 7a845b40dd..2a0541db08 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
@@ -15,14 +15,8 @@ namespace Exiled.Events.Patches.Events.Player
using Exiled.API.Features.Pools;
using Exiled.Events.Attributes;
using Exiled.Events.EventArgs.Player;
- using Footprinting;
using HarmonyLib;
- using Interactables;
- using Interactables.Interobjects.DoorUtils;
using InventorySystem.Items.MicroHID.Modules;
- using MapGeneration;
- using PlayerRoles.FirstPersonControl;
- using PlayerStatsSystem;
using static HarmonyLib.AccessTools;
From 6bad67244188a454d077a3c1ea41ae2f16c3adf7 Mon Sep 17 00:00:00 2001
From: Yamato
Date: Mon, 7 Apr 2025 23:14:49 +0200
Subject: [PATCH 13/15] IMicroHIDEvent
ExplodingMicroHID
---
.../EventArgs/Player/MicroHIDOpeningDoorEventArgs.cs | 2 +-
.../Patches/Events/Player/ExplodingMicroHid.cs | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/EXILED/Exiled.Events/EventArgs/Player/MicroHIDOpeningDoorEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/MicroHIDOpeningDoorEventArgs.cs
index a8bf27b722..36ff69e9b1 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/MicroHIDOpeningDoorEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/MicroHIDOpeningDoorEventArgs.cs
@@ -17,7 +17,7 @@ namespace Exiled.Events.EventArgs.Player
///
/// Contains all information before the micro opens a doors.
///
- public class MicroHIDOpeningDoorEventArgs : IDeniableEvent, IDoorEvent, IItemEvent
+ public class MicroHIDOpeningDoorEventArgs : IDeniableEvent, IDoorEvent, IMicroHIDEvent
{
///
/// Initializes a new instance of the class.
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
index 2a0541db08..6189c7fa67 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
@@ -1,5 +1,5 @@
// -----------------------------------------------------------------------
-//
+//
// Copyright (c) ExMod Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
//
@@ -21,12 +21,12 @@ namespace Exiled.Events.Patches.Events.Player
using static HarmonyLib.AccessTools;
///
- /// Patches .
- /// Adds the event.
+ /// Patches .
+ /// Adds the event.
///
[EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.ExplodingMicroHID))]
[HarmonyPatch(typeof(ChargeFireModeModule), nameof(ChargeFireModeModule.ServerExplode))]
- internal static class ExplodingMicroHid
+ internal static class ExplodingMicroHID
{
private static IEnumerable Transpiler(IEnumerable instructions, ILGenerator generator)
{
From 9044d4a186a64ddf46b430a2296bf805f78052a7 Mon Sep 17 00:00:00 2001
From: Yamato
Date: Mon, 7 Apr 2025 23:17:46 +0200
Subject: [PATCH 14/15] Remove Useless pragma warning
---
EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs | 2 --
1 file changed, 2 deletions(-)
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
index 6189c7fa67..2fdf38da46 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
@@ -5,8 +5,6 @@
//
// -----------------------------------------------------------------------
-#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
-
namespace Exiled.Events.Patches.Events.Player
{
using System.Collections.Generic;
From 50eb509779dcf2f980b1ec22799641217fdc505e Mon Sep 17 00:00:00 2001
From: Mike <146554836+MikeSus1@users.noreply.github.com>
Date: Thu, 10 Apr 2025 09:25:16 +0200
Subject: [PATCH 15/15] fix file name
---
.../Events/Player/{ExplodingMicroHid.cs => ExplodingMicroHID.cs} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename EXILED/Exiled.Events/Patches/Events/Player/{ExplodingMicroHid.cs => ExplodingMicroHID.cs} (100%)
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs b/EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHID.cs
similarity index 100%
rename from EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHid.cs
rename to EXILED/Exiled.Events/Patches/Events/Player/ExplodingMicroHID.cs