Files
RobustToolbox/Robust.Client/GameObjects/EntitySystems/ScaleVisualsSystem.cs
metalgearsloth fd625e0b30 Fix scale command (#2784)
* Fix scale command

Everything will be visualizers.

* comment for future coders
2022-05-04 22:49:42 +10:00

25 lines
733 B
C#

using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
namespace Robust.Client.GameObjects;
public sealed class ScaleVisualsSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AppearanceChangeEvent>(OnChangeData);
}
private void OnChangeData(ref AppearanceChangeEvent ev)
{
if (!ev.AppearanceData.TryGetValue(ScaleVisuals.Scale, out var scale) ||
!TryComp<SpriteComponent>(ev.Component.Owner, out var spriteComponent)) return;
var floatScale = (float) scale;
// Set it directly because prediction may call this multiple times.
spriteComponent.Scale = new Vector2(floatScale, floatScale);
}
}