* Cleanup warnings in MagazineVisualsSpriteTest * Cleanup warnings in WiresVisualizerSystem * Cleanup warnings in GunSystem.SpentAmmo * Cleanup warnings in GunSystem * Cleanup warnings in GunSystem.ChamberMagazine * Cleanup warnings in MeleeWeaponSystem.Effects * Cleanup warnings in ToggleableLightVisualsSystem * Cleanup warnings in StatusIconOverlay * Cleanup warnings in SpriteFadeSystem * Cleanup warnings in PdaVisualizerSystem * Cleanup warnings in EnvelopeSystem * Cleanup warnings in MechSystem * Cleanup warnings in MappingOverlay * Cleanup warnings in LockVisualizerSystem * Cleanup warnings in DragDropSystem * Cleanup warnings in GhostSystem * Cleanup warnings in TriggerSystem.Proximity * Cleanup warnings in DragonSystem * Cleanup warnings in PortableScrubberVisualsSystem * File-scoped namespace for PortableScrubberVisualsSystem
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using Content.Shared.Storage;
|
|
using Content.Shared.Lock;
|
|
using Robust.Client.GameObjects;
|
|
|
|
namespace Content.Client.Lock.Visualizers;
|
|
|
|
public sealed class LockVisualizerSystem : VisualizerSystem<LockVisualsComponent>
|
|
{
|
|
[Dependency] private readonly SpriteSystem _sprite = default!;
|
|
|
|
protected override void OnAppearanceChange(EntityUid uid, LockVisualsComponent comp, ref AppearanceChangeEvent args)
|
|
{
|
|
if (args.Sprite == null
|
|
|| !AppearanceSystem.TryGetData<bool>(uid, LockVisuals.Locked, out _, args.Component))
|
|
return;
|
|
|
|
// Lock state for the entity.
|
|
if (!AppearanceSystem.TryGetData<bool>(uid, LockVisuals.Locked, out var locked, args.Component))
|
|
locked = true;
|
|
|
|
var unlockedStateExist = args.Sprite.BaseRSI?.TryGetState(comp.StateUnlocked, out _);
|
|
|
|
if (AppearanceSystem.TryGetData<bool>(uid, StorageVisuals.Open, out var open, args.Component))
|
|
{
|
|
_sprite.LayerSetVisible((uid, args.Sprite), LockVisualLayers.Lock, !open);
|
|
}
|
|
else if (!(bool)unlockedStateExist!)
|
|
_sprite.LayerSetVisible((uid, args.Sprite), LockVisualLayers.Lock, locked);
|
|
|
|
if (!open && (bool)unlockedStateExist!)
|
|
{
|
|
_sprite.LayerSetRsiState((uid, args.Sprite), LockVisualLayers.Lock, locked ? comp.StateLocked : comp.StateUnlocked);
|
|
}
|
|
}
|
|
}
|
|
|
|
public enum LockVisualLayers : byte
|
|
{
|
|
Lock
|
|
}
|