2021-07-21 20:28:37 +10:00
|
|
|
using Content.Server.Doors.Components;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Doors;
|
2021-07-21 20:28:37 +10:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.Physics.Dynamics;
|
2021-02-12 07:02:14 -08:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Doors
|
2021-02-12 07:02:14 -08:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used on the server side to manage global access level overrides.
|
|
|
|
|
/// </summary>
|
2021-05-30 23:30:44 +10:00
|
|
|
internal sealed class DoorSystem : SharedDoorSystem
|
2021-02-12 07:02:14 -08:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines the base access behavior of all doors on the station.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public AccessTypes AccessType { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// How door access should be handled.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum AccessTypes
|
|
|
|
|
{
|
|
|
|
|
/// <summary> ID based door access. </summary>
|
|
|
|
|
Id,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Allows everyone to open doors, except external which airlocks are still handled with ID's
|
|
|
|
|
/// </summary>
|
|
|
|
|
AllowAllIdExternal,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Allows everyone to open doors, except external airlocks which are never allowed, even if the user has
|
|
|
|
|
/// ID access.
|
|
|
|
|
/// </summary>
|
|
|
|
|
AllowAllNoExternal,
|
|
|
|
|
/// <summary> Allows everyone to open all doors. </summary>
|
|
|
|
|
AllowAll
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
AccessType = AccessTypes.Id;
|
2021-07-21 20:28:37 +10:00
|
|
|
SubscribeLocalEvent<ServerDoorComponent, StartCollideEvent>(HandleCollide);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleCollide(EntityUid uid, ServerDoorComponent component, StartCollideEvent args)
|
|
|
|
|
{
|
2021-10-01 13:47:38 +02:00
|
|
|
if (!args.OtherFixture.Body.Owner.HasComponent<DoorBumpOpenerComponent>())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-21 20:28:37 +10:00
|
|
|
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);
|
2021-02-12 07:02:14 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|