Skip to content

Commit

Permalink
Fixed de powered airlocks/doors not being able to be closed
Browse files Browse the repository at this point in the history
Added new property "BeingPried" in Content.Shared.Doors.DoorComponent

Changed Content.Shared.Doors.Systems.SharedAirlockSystem OnBeforeDoorClosed() and CanChangeState() to check for BeingPried door flag

Changed Content.Shared.Doors.Systems.SharedDoorSystem OnAfterPry to set BeingPried to true when closing

Changed Content.Shared.Doors.Systems.SharedDoorSystem set BeingPried to false after CanClose is called
  • Loading branch information
zHonys committed Dec 20, 2024
1 parent f476526 commit bf926c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Content.Shared/Doors/Components/DoorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ private float? SecondsUntilStateChange
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool CanPry = true;

[DataField]
public bool BeingPried;

[DataField]
public ProtoId<ToolQualityPrototype> PryingQuality = "Prying";

Expand Down
7 changes: 3 additions & 4 deletions Content.Shared/Doors/Systems/SharedAirlockSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ private void OnBeforeDoorClosed(EntityUid uid, AirlockComponent airlock, BeforeD
// only block based on bolts / power status when initially closing the door, not when its already
// mid-transition. Particularly relevant for when the door was pried-closed with a crowbar, which bypasses
// the initial power-check.

if (TryComp(uid, out DoorComponent? door)
&& !door.Partial
&& !CanChangeState(uid, airlock))
&& !CanChangeState(uid, airlock, door.BeingPried))
{
args.Cancel();
}
Expand Down Expand Up @@ -174,8 +173,8 @@ public void SetSafety(AirlockComponent component, bool value)
component.Safety = value;
}

public bool CanChangeState(EntityUid uid, AirlockComponent component)
public bool CanChangeState(EntityUid uid, AirlockComponent component, bool isBeingPried = false)
{
return component.Powered && !DoorSystem.IsBolted(uid);
return component.Powered && !DoorSystem.IsBolted(uid) || !component.Powered && isBeingPried ;
}
}
3 changes: 3 additions & 0 deletions Content.Shared/Doors/Systems/SharedDoorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ private void OnAfterPry(EntityUid uid, DoorComponent door, ref PriedEvent args)
}
else if (door.State == DoorState.Open)
{
door.BeingPried = true;
_adminLog.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(args.User)} pried {ToPrettyString(uid)} closed");
StartClosing(uid, door, args.User, true);
}
Expand Down Expand Up @@ -486,11 +487,13 @@ public bool OnPartialClose(EntityUid uid, DoorComponent? door = null, PhysicsCom
door.NextStateChange = GameTiming.CurTime + door.OpenTimeTwo;
door.State = DoorState.Open;
AppearanceSystem.SetData(uid, DoorVisuals.State, DoorState.Open);
door.BeingPried = false;
Dirty(uid, door);
return false;
}

door.Partial = true;
door.BeingPried = false;
SetCollidable(uid, true, door, physics);
door.NextStateChange = GameTiming.CurTime + door.CloseTimeTwo;
Dirty(uid, door);
Expand Down

0 comments on commit bf926c8

Please sign in to comment.