Files
tbd-station-14/Content.Client/Doors/FirelockSystem.cs
nikthechampiongr df8b9a659e Firelock improvements part 1 (#26582)
* Change prying system and pryunpoweredcomp to allow for custom time modifiers

This will be useful if I go the route of making firelocks pryable when
unpowered instead of just being able to open and close instantly when
unpowered.

* Make firelocks properly predicted

Shared system made. Since atmos checks can only be done on the server we
just have it set relevant bools on the component and then dirty it.
Ditched atmos checks on trying to open, they now only happen whenever
firelocks are updated.

* Make firelocks pryable without a crowbar

While this usually would only allow you to do this when a door is
unpowered, firelocks do not have the airlock component which actually
does that check. As such firelocks will always allow you to pry them
open/closed by hand.

* Clean up System. Change update interval to be based on ticks. Move as much as possible to shared

* Make firelocks unable to emergency close for 2 seconds after being pried open

* Clean up

* More cleanup

* Reorganize SharedFirelockSystem methods to match Initialize order

---------

Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
2024-05-22 04:16:20 -07:00

42 lines
1.6 KiB
C#

using Content.Shared.Doors.Components;
using Content.Shared.Doors.Systems;
using Robust.Client.GameObjects;
namespace Content.Client.Doors;
public sealed class FirelockSystem : SharedFirelockSystem
{
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FirelockComponent, AppearanceChangeEvent>(OnAppearanceChange);
}
private void OnAppearanceChange(EntityUid uid, FirelockComponent comp, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
var boltedVisible = false;
var unlitVisible = false;
if (!_appearanceSystem.TryGetData<DoorState>(uid, DoorVisuals.State, out var state, args.Component))
state = DoorState.Closed;
if (_appearanceSystem.TryGetData<bool>(uid, DoorVisuals.Powered, out var powered, args.Component) && powered)
{
boltedVisible = _appearanceSystem.TryGetData<bool>(uid, DoorVisuals.BoltLights, out var lights, args.Component) && lights;
unlitVisible =
state == DoorState.Closing
|| state == DoorState.Opening
|| state == DoorState.Denying
|| (_appearanceSystem.TryGetData<bool>(uid, DoorVisuals.ClosedLights, out var closedLights, args.Component) && closedLights);
}
args.Sprite.LayerSetVisible(DoorVisualLayers.BaseUnlit, unlitVisible && !boltedVisible);
args.Sprite.LayerSetVisible(DoorVisualLayers.BaseBolted, boltedVisible);
}
}