CatStation/Content.Client/Actions/ActionIconVisualsSystem.cs
Whatstone d9ffbf1d03
Cleanup: AppearanceSystem.TryGetData to AppearanceChangeEvent.TryGetData (#45373)
* First impl. of appearance TryGetData cleanup

* Handful of fixes

* DamageVisuals: fix HandleDamage call, inheritdoc

* bunch of unused AppearanceSystem instances

* Handful more unused appearance systems, inheritdoc

* JetpackSystem: Ent<T>

* cleanup roundup, more Ent<T>

* a few lingering AppearanceSystem.TryGetData calls

* more lingering AppearanceData access

* Remove unnecessary inheritdoc

* once again, with feeling
2026-10-05 00:45:37 +00:00

32 lines
1.2 KiB
C#

using Content.Shared.Actions;
using Content.Shared.Actions.Components;
using Robust.Client.GameObjects;
using Robust.Shared.Utility;
namespace Content.Client.Actions;
public sealed partial class ActionIconVisualsSystem : VisualizerSystem<ActionComponent>
{
/// <inheritdoc/>
protected override void OnAppearanceChange(EntityUid uid, ActionComponent comp, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
if (args.TryGetData<SpriteSpecifier>(ActionState.DynamicIcon, out var icon))
{
if (icon is SpriteSpecifier.EntityPrototype)
SpriteSystem.LayerSetTexture((uid, args.Sprite), ActionVisuals.Icon, SpriteSystem.Frame0(icon));
else
SpriteSystem.LayerSetSprite((uid, args.Sprite), ActionVisuals.Icon, icon);
}
if (args.TryGetData<Color>(ActionState.Color, out var color))
{
SpriteSystem.LayerSetColor((uid, args.Sprite), ActionVisuals.Icon, color);
if (SpriteSystem.LayerExists((uid, args.Sprite), ActionVisuals.IconToggled))
SpriteSystem.LayerSetColor((uid, args.Sprite), ActionVisuals.IconToggled, color);
}
}
}