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>
This commit is contained in:
@@ -5,21 +5,26 @@ 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(EntityUid uid, StickyVisualizerComponent component, ComponentInit args)
|
||||
private void OnInit(Entity<StickyVisualizerComponent> ent, ref ComponentInit args)
|
||||
{
|
||||
if (!TryComp(uid, out SpriteComponent? sprite))
|
||||
if (!_spriteQuery.TryComp(ent, out var sprite))
|
||||
return;
|
||||
|
||||
component.DefaultDrawDepth = sprite.DrawDepth;
|
||||
ent.Comp.OriginalDrawDepth = sprite.DrawDepth;
|
||||
}
|
||||
|
||||
protected override void OnAppearanceChange(EntityUid uid, StickyVisualizerComponent component, ref AppearanceChangeEvent args)
|
||||
protected override void OnAppearanceChange(EntityUid uid, StickyVisualizerComponent comp, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
@@ -27,8 +32,7 @@ public sealed class StickyVisualizerSystem : VisualizerSystem<StickyVisualizerCo
|
||||
if (!AppearanceSystem.TryGetData<bool>(uid, StickyVisuals.IsStuck, out var isStuck, args.Component))
|
||||
return;
|
||||
|
||||
var drawDepth = isStuck ? component.StuckDrawDepth : component.DefaultDrawDepth;
|
||||
var drawDepth = isStuck ? comp.StuckDrawDepth : comp.OriginalDrawDepth;
|
||||
args.Sprite.DrawDepth = drawDepth;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user