C4 (#7486)
This commit is contained in:
36
Content.Client/Sticky/Visualizers/StickyVisualizerSystem.cs
Normal file
36
Content.Client/Sticky/Visualizers/StickyVisualizerSystem.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Content.Shared.Sticky.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Sticky.Visualizers;
|
||||
|
||||
public sealed class StickyVisualizerSystem : VisualizerSystem<StickyVisualizerComponent>
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<StickyVisualizerComponent, ComponentInit>(OnInit);
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, StickyVisualizerComponent component, ComponentInit args)
|
||||
{
|
||||
if (!TryComp(uid, out SpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
component.DefaultDrawDepth = sprite.DrawDepth;
|
||||
}
|
||||
|
||||
protected override void OnAppearanceChange(EntityUid uid, StickyVisualizerComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
base.OnAppearanceChange(uid, component, ref args);
|
||||
|
||||
if (!TryComp(uid, out SpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
if (!args.Component.TryGetData(StickyVisuals.IsStuck, out bool isStuck))
|
||||
return;
|
||||
|
||||
var drawDepth = isStuck ? component.StuckDrawDepth : component.DefaultDrawDepth;
|
||||
sprite.DrawDepth = drawDepth;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user