Files
tbd-station-14/Content.Server/Doors/Systems/DoorSystem.cs
2024-10-31 22:04:08 -04:00

54 lines
1.5 KiB
C#

using Content.Server.Access;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Doors.Components;
using Content.Shared.Doors.Systems;
using Content.Shared.Power;
using Robust.Shared.Physics.Components;
namespace Content.Server.Doors.Systems;
public sealed class DoorSystem : SharedDoorSystem
{
[Dependency] private readonly AirtightSystem _airtightSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DoorBoltComponent, PowerChangedEvent>(OnBoltPowerChanged);
}
protected override void SetCollidable(
EntityUid uid,
bool collidable,
DoorComponent? door = null,
PhysicsComponent? physics = null,
OccluderComponent? occluder = null)
{
if (!Resolve(uid, ref door))
return;
if (door.ChangeAirtight && TryComp(uid, out AirtightComponent? airtight))
_airtightSystem.SetAirblocked((uid, airtight), collidable);
// Pathfinding / AI stuff.
RaiseLocalEvent(new AccessReaderChangeEvent(uid, collidable));
base.SetCollidable(uid, collidable, door, physics, occluder);
}
private void OnBoltPowerChanged(Entity<DoorBoltComponent> ent, ref PowerChangedEvent args)
{
if (args.Powered)
{
if (ent.Comp.BoltWireCut)
SetBoltsDown(ent, true);
}
ent.Comp.Powered = args.Powered;
Dirty(ent, ent.Comp);
UpdateBoltLightStatus(ent);
}
}