1
0

FirelockSystem.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Content.Shared.Doors.Components;
  2. using Content.Shared.Doors.Systems;
  3. using Robust.Client.GameObjects;
  4. namespace Content.Client.Doors;
  5. public sealed class FirelockSystem : SharedFirelockSystem
  6. {
  7. [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
  8. public override void Initialize()
  9. {
  10. base.Initialize();
  11. SubscribeLocalEvent<FirelockComponent, AppearanceChangeEvent>(OnAppearanceChange);
  12. }
  13. private void OnAppearanceChange(EntityUid uid, FirelockComponent comp, ref AppearanceChangeEvent args)
  14. {
  15. if (args.Sprite == null)
  16. return;
  17. var boltedVisible = false;
  18. var unlitVisible = false;
  19. if (!_appearanceSystem.TryGetData<DoorState>(uid, DoorVisuals.State, out var state, args.Component))
  20. state = DoorState.Closed;
  21. boltedVisible = _appearanceSystem.TryGetData<bool>(uid, DoorVisuals.BoltLights, out var lights, args.Component) && lights;
  22. unlitVisible =
  23. state == DoorState.Closing
  24. || state == DoorState.Opening
  25. || state == DoorState.Denying
  26. || (_appearanceSystem.TryGetData<bool>(uid, DoorVisuals.ClosedLights, out var closedLights, args.Component) && closedLights);
  27. args.Sprite.LayerSetVisible(DoorVisualLayers.BaseUnlit, unlitVisible && !boltedVisible);
  28. args.Sprite.LayerSetVisible(DoorVisualLayers.BaseBolted, boltedVisible);
  29. }
  30. }