PotencyVisualsSystem.cs 737 B

123456789101112131415161718192021
  1. using System.Numerics;
  2. using Content.Shared.Botany;
  3. using Content.Client.Botany.Components;
  4. using Robust.Client.GameObjects;
  5. namespace Content.Client.Botany;
  6. public sealed class PotencyVisualsSystem : VisualizerSystem<PotencyVisualsComponent>
  7. {
  8. protected override void OnAppearanceChange(EntityUid uid, PotencyVisualsComponent component, ref AppearanceChangeEvent args)
  9. {
  10. if (args.Sprite == null)
  11. return;
  12. if (AppearanceSystem.TryGetData<float>(uid, ProduceVisuals.Potency, out var potency, args.Component))
  13. {
  14. var scale = MathHelper.Lerp(component.MinimumScale, component.MaximumScale, potency / 100);
  15. args.Sprite.Scale = new Vector2(scale, scale);
  16. }
  17. }
  18. }