1
0

InfantSystem.cs 1014 B

12345678910111213141516171819202122232425262728293031323334
  1. using Content.Shared.Nutrition.AnimalHusbandry;
  2. using Robust.Client.GameObjects;
  3. namespace Content.Client.Nutrition.EntitySystems;
  4. /// <summary>
  5. /// This handles visuals for <see cref="InfantComponent"/>
  6. /// </summary>
  7. public sealed class InfantSystem : EntitySystem
  8. {
  9. /// <inheritdoc/>
  10. public override void Initialize()
  11. {
  12. SubscribeLocalEvent<InfantComponent, ComponentStartup>(OnStartup);
  13. SubscribeLocalEvent<InfantComponent, ComponentShutdown>(OnShutdown);
  14. }
  15. private void OnStartup(EntityUid uid, InfantComponent component, ComponentStartup args)
  16. {
  17. if (!TryComp<SpriteComponent>(uid, out var sprite))
  18. return;
  19. component.DefaultScale = sprite.Scale;
  20. sprite.Scale = component.VisualScale;
  21. }
  22. private void OnShutdown(EntityUid uid, InfantComponent component, ComponentShutdown args)
  23. {
  24. if (!TryComp<SpriteComponent>(uid, out var sprite))
  25. return;
  26. sprite.Scale = component.DefaultScale;
  27. }
  28. }