Skip to content

Commit

Permalink
Firelocks are no longer pryable by hand if they are powered (#29221)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikthechampiongr authored Jun 22, 2024
1 parent 061445e commit 6aced66
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
9 changes: 9 additions & 0 deletions Content.Shared/Doors/Systems/SharedFirelockSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public override void Initialize()

// Access/Prying
SubscribeLocalEvent<FirelockComponent, BeforeDoorOpenedEvent>(OnBeforeDoorOpened);
SubscribeLocalEvent<FirelockComponent, BeforePryEvent>(OnBeforePry);
SubscribeLocalEvent<FirelockComponent, GetPryTimeModifierEvent>(OnDoorGetPryTimeModifier);
SubscribeLocalEvent<FirelockComponent, PriedEvent>(OnAfterPried);

Expand Down Expand Up @@ -60,6 +61,14 @@ private void OnBeforeDoorOpened(EntityUid uid, FirelockComponent component, Befo
WarnPlayer((uid, component), args.User.Value);
}

private void OnBeforePry(EntityUid uid, FirelockComponent component, ref BeforePryEvent args)
{
if (args.Cancelled || !component.Powered || args.StrongPry || args.PryPowered)
return;

args.Cancelled = true;
}

private void OnDoorGetPryTimeModifier(EntityUid uid, FirelockComponent component, ref GetPryTimeModifierEvent args)
{
WarnPlayer((uid, component), args.User);
Expand Down
14 changes: 13 additions & 1 deletion Content.Shared/Prying/Components/PryingComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,26 @@ public sealed partial class PryingComponent : Component
/// Cancel to stop the entity from being pried open.
/// </summary>
[ByRefEvent]
public record struct BeforePryEvent(EntityUid User, bool PryPowered, bool Force)
public record struct BeforePryEvent(EntityUid User, bool PryPowered, bool Force, bool StrongPry)
{
public readonly EntityUid User = User;

/// <summary>
/// Whether prying should be allowed even if whatever is being pried is powered.
/// </summary>
public readonly bool PryPowered = PryPowered;

/// <summary>
/// Whether prying should be allowed to go through under most circumstances. (E.g. airlock is bolted).
/// Systems may still wish to ignore this occasionally.
/// </summary>
public readonly bool Force = Force;

/// <summary>
/// Whether anything other than bare hands were used. This should only be false if prying is being performed without a prying comp.
/// </summary>
public readonly bool StrongPry = StrongPry;

public string? Message;

public bool Cancelled;
Expand Down
4 changes: 2 additions & 2 deletions Content.Shared/Prying/Systems/PryingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private bool CanPry(EntityUid target, EntityUid user, out string? message, Pryin

if (comp != null || Resolve(user, ref comp, false))
{
canev = new BeforePryEvent(user, comp.PryPowered, comp.Force);
canev = new BeforePryEvent(user, comp.PryPowered, comp.Force, true);
}
else
{
Expand All @@ -119,7 +119,7 @@ private bool CanPry(EntityUid target, EntityUid user, out string? message, Pryin
return false;
}

canev = new BeforePryEvent(user, false, false);
canev = new BeforePryEvent(user, false, false, false);
}

RaiseLocalEvent(target, ref canev);
Expand Down

0 comments on commit 6aced66

Please sign in to comment.