CatStation/Content.Client/Lock/Visualizers/LockVisualizerSystem.cs
Whatstone d9ffbf1d03
Cleanup: AppearanceSystem.TryGetData to AppearanceChangeEvent.TryGetData (#45373)
* First impl. of appearance TryGetData cleanup

* Handful of fixes

* DamageVisuals: fix HandleDamage call, inheritdoc

* bunch of unused AppearanceSystem instances

* Handful more unused appearance systems, inheritdoc

* JetpackSystem: Ent<T>

* cleanup roundup, more Ent<T>

* a few lingering AppearanceSystem.TryGetData calls

* more lingering AppearanceData access

* Remove unnecessary inheritdoc

* once again, with feeling
2026-10-05 00:45:37 +00:00

34 lines
1.1 KiB
C#

using Content.Shared.Storage;
using Content.Shared.Lock;
using Robust.Client.GameObjects;
namespace Content.Client.Lock.Visualizers;
public sealed partial class LockVisualizerSystem : VisualizerSystem<LockVisualsComponent>
{
protected override void OnAppearanceChange(EntityUid uid, LockVisualsComponent comp, ref AppearanceChangeEvent args)
{
if (args.Sprite == null
|| !args.TryGetData<bool>(LockVisuals.Locked, out var locked))
return;
var unlockedStateExist = args.Sprite.BaseRSI?.TryGetState(comp.StateUnlocked, out _);
if (args.TryGetData<bool>(StorageVisuals.Open, out var open))
{
SpriteSystem.LayerSetVisible((uid, args.Sprite), LockVisualLayers.Lock, !open);
}
else if (!(bool)unlockedStateExist!)
SpriteSystem.LayerSetVisible((uid, args.Sprite), LockVisualLayers.Lock, locked);
if (!open && (bool)unlockedStateExist!)
{
SpriteSystem.LayerSetRsiState((uid, args.Sprite), LockVisualLayers.Lock, locked ? comp.StateLocked : comp.StateUnlocked);
}
}
}
public enum LockVisualLayers : byte
{
Lock
}