Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firelocks are no longer pryable by hand if they are powered #29221

Merged
merged 4 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 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,18 @@ 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)
return;

if (!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
Loading