Files
tbd-station-14/Content.Client/Sticky/Visualizers/StickyVisualizerSystem.cs
deltanedas e4ff5780d5 full sticky prediction (#30230)
* move all sticky stuff to shared and cleanup/grammar fix

* update imports and ref

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
2024-08-09 09:36:15 +10:00

39 lines
1.1 KiB
C#

using Content.Shared.Sticky.Components;
using Robust.Client.GameObjects;
namespace Content.Client.Sticky.Visualizers;
public sealed class StickyVisualizerSystem : VisualizerSystem<StickyVisualizerComponent>
{
private EntityQuery<SpriteComponent> _spriteQuery;
public override void Initialize()
{
base.Initialize();
_spriteQuery = GetEntityQuery<SpriteComponent>();
SubscribeLocalEvent<StickyVisualizerComponent, ComponentInit>(OnInit);
}
private void OnInit(Entity<StickyVisualizerComponent> 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<bool>(uid, StickyVisuals.IsStuck, out var isStuck, args.Component))
return;
var drawDepth = isStuck ? comp.StuckDrawDepth : comp.OriginalDrawDepth;
args.Sprite.DrawDepth = drawDepth;
}
}