Files
tbd-station-14/Content.Server/Doors/Systems/DoorSystem.cs
Nemanja ce0a51fc29 Predict doors and airlocks (#25419)
* predict doors and airlocks

* prying, too

* ack

* eek
2024-02-23 10:01:31 +11:00

54 lines
1.5 KiB
C#

using Content.Server.Access;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Power.Components;
using Content.Shared.Doors.Components;
using Content.Shared.Doors.Systems;
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);
}
UpdateBoltLightStatus(ent);
ent.Comp.Powered = args.Powered;
Dirty(ent, ent.Comp);
}
}