mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 11:40:52 +01:00
25 lines
705 B
C#
25 lines
705 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 vecScale = (Vector2)scale;
|
|
|
|
// Set it directly because prediction may call this multiple times.
|
|
spriteComponent.Scale = vecScale;
|
|
}
|
|
}
|