From 055191930eea3277260f53efed5f654e644e295a Mon Sep 17 00:00:00 2001
From: R2kip <56793105+R2kip@users.noreply.github.com>
Date: Fri, 23 May 2025 00:34:52 +0300
Subject: [PATCH] Add CanInteract in InteractingLocker event
---
.../Player/InteractingLockerEventArgs.cs | 8 +++++++-
.../Patches/Events/Player/InteractingDoor.cs | 2 +-
.../Patches/Events/Player/InteractingLocker.cs | 15 ++++++++++++++-
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/EXILED/Exiled.Events/EventArgs/Player/InteractingLockerEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/InteractingLockerEventArgs.cs
index b7cc7f3b5c..022c7782ba 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/InteractingLockerEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/InteractingLockerEventArgs.cs
@@ -37,6 +37,7 @@ public InteractingLockerEventArgs(Player player, MapGeneration.Distributors.Lock
InteractingLocker = Locker.Get(locker);
InteractingChamber = Chamber.Get(locker.Chambers[colliderId]);
IsAllowed = isAllowed;
+ CanInteract = true;
}
///
@@ -50,10 +51,15 @@ public InteractingLockerEventArgs(Player player, MapGeneration.Distributors.Lock
public Chamber InteractingChamber { get; }
///
- /// Gets or sets a value indicating whether the player can interact with the locker.
+ /// Gets or sets a value indicating whether the player can access the locker.
///
public bool IsAllowed { get; set; }
+ ///
+ /// Gets or sets a value indicating whether the player can interact with the locker.
+ ///
+ public bool CanInteract { get; set; }
+
///
/// Gets the player who's interacting with the locker.
///
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs b/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs
index dcdb2911f3..485b4ef14e 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/InteractingDoor.cs
@@ -25,7 +25,7 @@ namespace Exiled.Events.Patches.Events.Player
/// Patches .
/// Adds the event.
///
- [EventPatch(typeof(Handlers.Player), nameof(Player.InteractingDoor))]
+ [EventPatch(typeof(Handlers.Player), nameof(Handlers.Player.InteractingDoor))]
[HarmonyPatch(typeof(DoorVariant), nameof(DoorVariant.ServerInteract), typeof(ReferenceHub), typeof(byte))]
internal static class InteractingDoor
{
diff --git a/EXILED/Exiled.Events/Patches/Events/Player/InteractingLocker.cs b/EXILED/Exiled.Events/Patches/Events/Player/InteractingLocker.cs
index 3ce7b9aeee..03f53ccabe 100644
--- a/EXILED/Exiled.Events/Patches/Events/Player/InteractingLocker.cs
+++ b/EXILED/Exiled.Events/Patches/Events/Player/InteractingLocker.cs
@@ -33,7 +33,11 @@ private static IEnumerable Transpiler(IEnumerable newInstructions = ListPool.Pool.Get(instructions);
- int offset = -9;
+ LocalBuilder evLocal = generator.DeclareLocal(typeof(InteractingLockerEventArgs));
+
+ Label retLabel = generator.DefineLabel();
+
+ const int offset = -9;
int index = newInstructions.FindIndex(i => i.opcode == OpCodes.Newobj && (ConstructorInfo)i.operand == GetDeclaredConstructors(typeof(LabApi.Events.Arguments.PlayerEvents.PlayerInteractingLockerEventArgs))[0]) + offset;
newInstructions.InsertRange(
@@ -58,17 +62,26 @@ private static IEnumerable Transpiler(IEnumerable