Firelocks only open on click (not close) (#16516)

This commit is contained in:
Tom Leys
2023-05-17 18:37:37 +12:00
committed by GitHub
parent ae926b0dba
commit 9fce417662
3 changed files with 35 additions and 36 deletions

View File

@@ -27,7 +27,6 @@ namespace Content.Server.Doors.Systems;
public sealed class DoorSystem : SharedDoorSystem
{
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
[Dependency] private readonly AirlockSystem _airlock = default!;
[Dependency] private readonly AirtightSystem _airtightSystem = default!;
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
@@ -208,34 +207,6 @@ public sealed class DoorSystem : SharedDoorSystem
}
#endregion
/// <summary>
/// Does the user have the permissions required to open this door?
/// </summary>
public override bool HasAccess(EntityUid uid, EntityUid? user = null, AccessReaderComponent? access = null)
{
// TODO network AccessComponent for predicting doors
// if there is no "user" we skip the access checks. Access is also ignored in some game-modes.
if (user == null || AccessType == AccessTypes.AllowAll)
return true;
// If the door is on emergency access we skip the checks.
if (TryComp<AirlockComponent>(uid, out var airlock) && airlock.EmergencyAccess)
return true;
if (!Resolve(uid, ref access, false))
return true;
var isExternal = access.AccessLists.Any(list => list.Contains("External"));
return AccessType switch
{
// Some game modes modify access rules.
AccessTypes.AllowAllIdExternal => !isExternal || _accessReaderSystem.IsAllowed(user.Value, access),
AccessTypes.AllowAllNoExternal => !isExternal,
_ => _accessReaderSystem.IsAllowed(user.Value, access)
};
}
/// <summary>
/// Open a door if a player or door-bumper (PDA, ID-card) collide with the door. Sadly, bullets no longer

View File

@@ -74,7 +74,7 @@ namespace Content.Server.Remotes
}
if (TryComp<AccessReaderComponent>(args.Target, out var accessComponent) &&
!_doorSystem.HasAccess(args.Target.Value, args.Used, accessComponent))
!_doorSystem.HasAccess(args.Target.Value, args.Used, doorComp, accessComponent))
{
_doorSystem.Deny(args.Target.Value, doorComp, args.User);
ShowPopupToUser("door-remote-denied", args.User);

View File

@@ -1,5 +1,6 @@
using System.Linq;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
using Content.Shared.Doors.Components;
@@ -29,6 +30,7 @@ public abstract class SharedDoorSystem : EntitySystem
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] protected readonly SharedAppearanceSystem AppearanceSystem = default!;
[Dependency] private readonly OccluderSystem _occluder = default!;
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
/// <summary>
/// A body must have an intersection percentage larger than this in order to be considered as colliding with a
@@ -252,7 +254,7 @@ public abstract class SharedDoorSystem : EntitySystem
if (ev.Cancelled)
return false;
if (!HasAccess(uid, user))
if (!HasAccess(uid, user, door))
{
if (!quiet)
Deny(uid, door);
@@ -325,7 +327,7 @@ public abstract class SharedDoorSystem : EntitySystem
if (ev.Cancelled)
return false;
if (!HasAccess(uid, user))
if (!HasAccess(uid, user, door))
return false;
return !ev.PerformCollisionCheck || !GetColliding(uid).Any();
@@ -476,13 +478,39 @@ public abstract class SharedDoorSystem : EntitySystem
#endregion
#region Access
public virtual bool HasAccess(EntityUid uid, EntityUid? user = null, AccessReaderComponent? access = null)
/// <summary>
/// Does the user have the permissions required to open this door?
/// </summary>
public bool HasAccess(EntityUid uid, EntityUid? user = null, DoorComponent? door = null, AccessReaderComponent? access = null)
{
// TODO network AccessComponent for predicting doors
// Currently all door open/close & door-bumper collision stuff is done server side.
// so this return value means nothing.
// if there is no "user" we skip the access checks. Access is also ignored in some game-modes.
if (user == null || AccessType == AccessTypes.AllowAll)
return true;
// If the door is on emergency access we skip the checks.
if (TryComp<AirlockComponent>(uid, out var airlock) && airlock.EmergencyAccess)
return true;
// Can't click to close firelocks.
if (Resolve(uid, ref door) && door.State == DoorState.Open &&
TryComp<FirelockComponent>(uid, out var firelock))
return false;
if (!Resolve(uid, ref access, false))
return true;
var isExternal = access.AccessLists.Any(list => list.Contains("External"));
return AccessType switch
{
// Some game modes modify access rules.
AccessTypes.AllowAllIdExternal => !isExternal || _accessReaderSystem.IsAllowed(user.Value, access),
AccessTypes.AllowAllNoExternal => !isExternal,
_ => _accessReaderSystem.IsAllowed(user.Value, access)
};
}
/// <summary>