1
0

PillSystem.cs 667 B

123456789101112131415161718192021222324
  1. using Content.Shared.Chemistry.Components;
  2. using Robust.Client.GameObjects;
  3. namespace Content.Client.Chemistry.EntitySystems;
  4. public sealed class PillSystem : EntitySystem
  5. {
  6. public override void Initialize()
  7. {
  8. base.Initialize();
  9. SubscribeLocalEvent<PillComponent, AfterAutoHandleStateEvent>(OnHandleState);
  10. }
  11. private void OnHandleState(EntityUid uid, PillComponent component, ref AfterAutoHandleStateEvent args)
  12. {
  13. if (!TryComp(uid, out SpriteComponent? sprite))
  14. return;
  15. if (!sprite.TryGetLayer(0, out var layer))
  16. return;
  17. layer.SetState($"pill{component.PillType + 1}");
  18. }
  19. }