Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesus-QC authored Sep 24, 2024
2 parents 6e2f1fd + 5b93a20 commit 76f196b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions EXILED/EXILED.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<PropertyGroup>
<!-- This is the global version and is used for all projects that don't have a version -->
<Version Condition="$(Version) == ''">8.12.0</Version>
<Version Condition="$(Version) == ''">8.12.1</Version>
<!-- Enables public beta warning via the PUBLIC_BETA constant -->
<PublicBeta>false</PublicBeta>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ public class InteractingLockerEventArgs : IPlayerEvent, IDeniableEvent
/// <param name="player">
/// <inheritdoc cref="Player" />
/// </param>
/// <param name="lockerChamber">
/// <param name="locker">
/// <inheritdoc cref="InteractingLocker" />
/// </param>
/// <param name="colliderId">
/// <inheritdoc cref="InteractingChamber" />
/// </param>
/// <param name="isAllowed">
/// <inheritdoc cref="IsAllowed" />
/// </param>
public InteractingLockerEventArgs(Player player, MapGeneration.Distributors.LockerChamber lockerChamber, bool isAllowed)
public InteractingLockerEventArgs(Player player, MapGeneration.Distributors.Locker locker, byte colliderId, bool isAllowed)
{
Player = player;
InteractingChamber = API.Features.Lockers.Chamber.Get(lockerChamber);
InteractingLocker = API.Features.Lockers.Locker.Get(locker);
InteractingChamber = API.Features.Lockers.Chamber.Get(locker.Chambers[colliderId]);
IsAllowed = isAllowed;
}

Expand All @@ -52,7 +56,7 @@ public InteractingLockerEventArgs(Player player, MapGeneration.Distributors.Lock
/// <summary>
/// Gets the locker which is containing <see cref="InteractingChamber"/>.
/// </summary>
public Locker InteractingLocker => InteractingChamber.Locker;
public Locker InteractingLocker { get; }

/// <summary>
/// Gets the interacting chamber.
Expand Down
13 changes: 6 additions & 7 deletions EXILED/Exiled.Events/Patches/Events/Player/InteractingLocker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,28 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
{
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);

const int offset = -9;
int index = newInstructions.FindIndex(instruction => instruction.opcode == OpCodes.Newobj) + offset;
int index = newInstructions.FindLastIndex(instruction => instruction.opcode == OpCodes.Ldloc_0);

newInstructions.InsertRange(
index,
new[]
{
// Player.Get(ply);
new CodeInstruction(OpCodes.Ldarg_1),
new CodeInstruction(OpCodes.Ldarg_1).MoveLabelsFrom(newInstructions[index]),
new(OpCodes.Call, Method(typeof(Player), nameof(Player.Get), new[] { typeof(ReferenceHub) })),

// this.Chambers[colliderId]
// this
new(OpCodes.Ldarg_0),
new(OpCodes.Ldfld, Field(typeof(Locker), nameof(Locker.Chambers))),

// colliderId
new(OpCodes.Ldarg_2),
new(OpCodes.Ldelem_Ref),

// !flag
new(OpCodes.Ldloc_0),
new(OpCodes.Ldc_I4_0),
new(OpCodes.Ceq),

// InteractingLockerEventArgs ev = new(Player, Locker, LockerChamber, byte, bool)
// InteractingLockerEventArgs ev = new(Player, Locker, byte, bool)
new CodeInstruction(OpCodes.Newobj, GetDeclaredConstructors(typeof(InteractingLockerEventArgs))[0]),
new(OpCodes.Dup),

Expand Down

0 comments on commit 76f196b

Please sign in to comment.