CatStation/Content.Client/Sprite/ScaleVisualsSystem.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
940 B
C#

using System.Numerics;
using Content.Shared.Sprite;
using Robust.Client.GameObjects;
namespace Content.Client.Sprite;
public sealed partial class ScaleVisualsSystem : SharedScaleVisualsSystem
{
[Dependency] private SpriteSystem _sprite = default!;
[SubscribeLocalEvent]
private void OnChangeData(Entity<ScaleVisualsComponent> ent, ref AppearanceChangeEvent args)
{
if (args.Sprite == null
|| !args.TryGetData<Vector2>(ScaleVisuals.Scale, out var scale))
return;
// save the original scale
ent.Comp.OriginalScale ??= args.Sprite.Scale;
_sprite.SetScale((ent.Owner, args.Sprite), scale);
}
// revert to the original scale
protected override void ResetScale(Entity<ScaleVisualsComponent> ent)
{
base.ResetScale(ent);
if (ent.Comp.OriginalScale != null)
_sprite.SetScale(ent.Owner, ent.Comp.OriginalScale.Value);
}
}