mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* 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
32 lines
940 B
C#
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);
|
|
}
|
|
}
|