Files
OldThink/Content.Server/Doors/Systems/DoorSystem.cs

54 lines
1.5 KiB
C#
Raw Normal View History

2022-01-30 13:49:56 +13:00
using Content.Server.Access;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Power.Components;
2022-01-30 13:49:56 +13:00
using Content.Shared.Doors.Components;
using Content.Shared.Doors.Systems;
using Robust.Shared.Physics.Components;
2022-01-30 13:49:56 +13:00
namespace Content.Server.Doors.Systems;
public sealed class DoorSystem : SharedDoorSystem
{
[Dependency] private readonly AirtightSystem _airtightSystem = default!;
2022-01-30 13:49:56 +13:00
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DoorBoltComponent, PowerChangedEvent>(OnBoltPowerChanged);
2023-06-17 12:09:49 +10:00
}
protected override void SetCollidable(
EntityUid uid,
bool collidable,
2022-02-20 08:34:01 +13:00
DoorComponent? door = null,
PhysicsComponent? physics = null,
OccluderComponent? occluder = null)
2022-01-30 20:30:24 +13:00
{
2022-02-20 08:34:01 +13:00
if (!Resolve(uid, ref door))
return;
2022-01-30 20:30:24 +13:00
2022-02-20 08:34:01 +13:00
if (door.ChangeAirtight && TryComp(uid, out AirtightComponent? airtight))
_airtightSystem.SetAirblocked((uid, airtight), collidable);
2022-02-20 08:34:01 +13:00
// Pathfinding / AI stuff.
2022-05-16 13:21:00 +10:00
RaiseLocalEvent(new AccessReaderChangeEvent(uid, collidable));
2022-02-20 08:34:01 +13:00
base.SetCollidable(uid, collidable, door, physics, occluder);
2022-01-30 20:30:24 +13:00
}
private void OnBoltPowerChanged(Entity<DoorBoltComponent> ent, ref PowerChangedEvent args)
{
if (args.Powered)
{
if (ent.Comp.BoltWireCut)
SetBoltsDown(ent, true);
}
UpdateBoltLightStatus(ent);
ent.Comp.Powered = args.Powered;
Dirty(ent, ent.Comp);
}
}