DoorSystem.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Content.Server.Access;
  2. using Content.Server.Atmos.Components;
  3. using Content.Server.Atmos.EntitySystems;
  4. using Content.Shared.Doors.Components;
  5. using Content.Shared.Doors.Systems;
  6. using Content.Shared.Power;
  7. using Robust.Shared.Physics.Components;
  8. namespace Content.Server.Doors.Systems;
  9. public sealed class DoorSystem : SharedDoorSystem
  10. {
  11. [Dependency] private readonly AirtightSystem _airtightSystem = default!;
  12. public override void Initialize()
  13. {
  14. base.Initialize();
  15. SubscribeLocalEvent<DoorBoltComponent, PowerChangedEvent>(OnBoltPowerChanged);
  16. }
  17. protected override void SetCollidable(
  18. EntityUid uid,
  19. bool collidable,
  20. DoorComponent? door = null,
  21. PhysicsComponent? physics = null,
  22. OccluderComponent? occluder = null)
  23. {
  24. if (!Resolve(uid, ref door))
  25. return;
  26. if (door.ChangeAirtight && TryComp(uid, out AirtightComponent? airtight))
  27. _airtightSystem.SetAirblocked((uid, airtight), collidable);
  28. // Pathfinding / AI stuff.
  29. RaiseLocalEvent(new AccessReaderChangeEvent(uid, collidable));
  30. base.SetCollidable(uid, collidable, door, physics, occluder);
  31. }
  32. private void OnBoltPowerChanged(Entity<DoorBoltComponent> ent, ref PowerChangedEvent args)
  33. {
  34. if (args.Powered)
  35. {
  36. if (ent.Comp.BoltWireCut)
  37. SetBoltsDown(ent, true);
  38. }
  39. ent.Comp.Powered = args.Powered;
  40. Dirty(ent, ent.Comp);
  41. UpdateBoltLightStatus(ent);
  42. }
  43. }