CatStation/Content.Client/Sticky/Visualizers/StickyVisualizerSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

36 lines
1.1 KiB
C#

using Content.Shared.Sticky.Components;
using Robust.Client.GameObjects;
namespace Content.Client.Sticky.Visualizers;
public sealed partial class StickyVisualizerSystem : VisualizerSystem<StickyVisualizerComponent>
{
[Dependency] private EntityQuery<SpriteComponent> _spriteQuery = default!;
public override void Initialize()
{
base.Initialize();
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;
SpriteSystem.SetDrawDepth((uid, args.Sprite), drawDepth);
}
}