Skip to content

Commit

Permalink
InteractingElevator::IsCalledFromInside
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed Dec 24, 2024
1 parent 282f6bf commit 9ebcd29
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@ public class InteractingElevatorEventArgs : IPlayerEvent, IDeniableEvent
/// <param name="elevator">
/// <inheritdoc cref="Elevator" />
/// </param>
/// <param name="isCalledFromInside">
/// <inheritdoc cref="IsCalledFromInside" />
/// </param>
/// <param name="isAllowed">
/// <inheritdoc cref="IsAllowed" />
/// </param>
public InteractingElevatorEventArgs(Player player, ElevatorChamber elevator, bool isAllowed = true)
public InteractingElevatorEventArgs(Player player, ElevatorChamber elevator, bool isCalledFromInside, bool isAllowed = true)
{
Player = player;
Lift = Lift.Get(elevator);
Elevator = elevator;
IsCalledFromInside = isCalledFromInside;
IsAllowed = isAllowed;
}

Expand All @@ -54,6 +58,11 @@ public InteractingElevatorEventArgs(Player player, ElevatorChamber elevator, boo
/// </summary>
public bool IsAllowed { get; set; }

/// <summary>
/// Gets a value indicating whether the player as interact with the elevator from the inside.
/// </summary>
public bool IsCalledFromInside { get; }

/// <summary>
/// Gets the player who's interacting with the elevator.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
new(OpCodes.Ldarg_0),
new(OpCodes.Ldfld, Field(typeof(ElevatorDoor), nameof(ElevatorDoor.Chamber))),

// false
new(OpCodes.Ldc_I4_0),

// true
new(OpCodes.Ldc_I4_1),

// InteractingElevatorEventArgs ev = new(Player, ElevatorChamber, bool)
// InteractingElevatorEventArgs ev = new(Player, ElevatorChamber, bool, bool)
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(InteractingElevatorEventArgs))[0]),
new(OpCodes.Dup),

Expand Down Expand Up @@ -113,7 +116,10 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
// true
new(OpCodes.Ldc_I4_1),

// InteractingElevatorEventArgs ev = new(Player, ElevatorChamber, bool)
// true
new(OpCodes.Ldc_I4_1),

// InteractingElevatorEventArgs ev = new(Player, ElevatorChamber, bool, bool)
new(OpCodes.Newobj, GetDeclaredConstructors(typeof(InteractingElevatorEventArgs))[0]),
new(OpCodes.Dup),

Expand Down

0 comments on commit 9ebcd29

Please sign in to comment.