Cleanup warnings in DamageStateVisualizerSystem (#37435)

Cleanup warnings in DamageStateVisualizerSystem
This commit is contained in:
Tayrtahn
2025-05-13 21:58:03 -04:00
committed by GitHub
parent d957cdb144
commit a9e0d8725e

View File

@@ -6,6 +6,8 @@ namespace Content.Client.DamageState;
public sealed class DamageStateVisualizerSystem : VisualizerSystem<DamageStateVisualsComponent>
{
[Dependency] private readonly SpriteSystem _sprite = default!;
protected override void OnAppearanceChange(EntityUid uid, DamageStateVisualsComponent component, ref AppearanceChangeEvent args)
{
var sprite = args.Sprite;
@@ -21,34 +23,34 @@ public sealed class DamageStateVisualizerSystem : VisualizerSystem<DamageStateVi
}
// Brain no worky rn so this was just easier.
foreach (var key in new []{ DamageStateVisualLayers.Base, DamageStateVisualLayers.BaseUnshaded })
foreach (var key in new[] { DamageStateVisualLayers.Base, DamageStateVisualLayers.BaseUnshaded })
{
if (!sprite.LayerMapTryGet(key, out _)) continue;
if (!_sprite.LayerMapTryGet((uid, sprite), key, out _, false)) continue;
sprite.LayerSetVisible(key, false);
_sprite.LayerSetVisible((uid, sprite), key, false);
}
foreach (var (key, state) in layers)
{
// Inheritance moment.
if (!sprite.LayerMapTryGet(key, out _)) continue;
if (!_sprite.LayerMapTryGet((uid, sprite), key, out _, false)) continue;
sprite.LayerSetVisible(key, true);
sprite.LayerSetState(key, state);
_sprite.LayerSetVisible((uid, sprite), key, true);
_sprite.LayerSetRsiState((uid, sprite), key, state);
}
// So they don't draw over mobs anymore
if (data == MobState.Dead)
{
if (sprite.DrawDepth > (int) DrawDepth.DeadMobs)
if (sprite.DrawDepth > (int)DrawDepth.DeadMobs)
{
component.OriginalDrawDepth = sprite.DrawDepth;
sprite.DrawDepth = (int) DrawDepth.DeadMobs;
_sprite.SetDrawDepth((uid, sprite), (int)DrawDepth.DeadMobs);
}
}
else if (component.OriginalDrawDepth != null)
{
sprite.DrawDepth = component.OriginalDrawDepth.Value;
_sprite.SetDrawDepth((uid, sprite), component.OriginalDrawDepth.Value);
component.OriginalDrawDepth = null;
}
}