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!;
}
#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
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;
[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
if (ev.Cancelled)
return false;
- if (!HasAccess(uid, user))
+ if (!HasAccess(uid, user, door))
{
if (!quiet)
Deny(uid, door);
if (ev.Cancelled)
return false;
- if (!HasAccess(uid, user))
+ if (!HasAccess(uid, user, door))
return false;
return !ev.PerformCollisionCheck || !GetColliding(uid).Any();
#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.
- return true;
+ // 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>