using Content.Shared.Sticky.Components; using Robust.Client.GameObjects; namespace Content.Client.Sticky.Visualizers; public sealed class StickyVisualizerSystem : VisualizerSystem { private EntityQuery _spriteQuery; public override void Initialize() { base.Initialize(); _spriteQuery = GetEntityQuery(); SubscribeLocalEvent(OnInit); } private void OnInit(Entity ent, ref ComponentInit args) { if (!_spriteQuery.TryComp(ent, out var sprite)) return; ent.Comp.OriginalDrawDepth = sprite.DrawDepth; } protected override void OnAppearanceChange(EntityUid uid, StickyVisualizerComponent comp, ref AppearanceChangeEvent args) { if (args.Sprite == null) return; if (!AppearanceSystem.TryGetData(uid, StickyVisuals.IsStuck, out var isStuck, args.Component)) return; var drawDepth = isStuck ? comp.StuckDrawDepth : comp.OriginalDrawDepth; SpriteSystem.SetDrawDepth((uid, args.Sprite), drawDepth); } }