using Content.Server.Doors.Components;
using Content.Shared.Doors;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics.Dynamics;
namespace Content.Server.Doors
{
///
/// Used on the server side to manage global access level overrides.
///
internal sealed class DoorSystem : SharedDoorSystem
{
///
/// Determines the base access behavior of all doors on the station.
///
public AccessTypes AccessType { get; set; }
///
/// How door access should be handled.
///
public enum AccessTypes
{
/// ID based door access.
Id,
///
/// Allows everyone to open doors, except external which airlocks are still handled with ID's
///
AllowAllIdExternal,
///
/// Allows everyone to open doors, except external airlocks which are never allowed, even if the user has
/// ID access.
///
AllowAllNoExternal,
/// Allows everyone to open all doors.
AllowAll
}
public override void Initialize()
{
base.Initialize();
AccessType = AccessTypes.Id;
SubscribeLocalEvent(HandleCollide);
}
private void HandleCollide(EntityUid uid, ServerDoorComponent component, StartCollideEvent args)
{
if (!args.OtherFixture.Body.Owner.HasComponent())
{
return;
}
if (component.State != SharedDoorComponent.DoorState.Closed)
{
return;
}
if (!component.BumpOpen)
{
return;
}
// Disabled because it makes it suck hard to walk through double doors.
component.TryOpen(args.OtherFixture.Body.Owner);
}
}
}