1
0

Hungry.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Content.Server.Administration;
  2. using Content.Shared.Administration;
  3. using Content.Shared.Nutrition.Components;
  4. using Content.Shared.Nutrition.EntitySystems;
  5. using Robust.Shared.Console;
  6. namespace Content.Server.Nutrition;
  7. [AdminCommand(AdminFlags.Debug)]
  8. public sealed class Hungry : LocalizedEntityCommands
  9. {
  10. public override string Command => "hungry";
  11. public override void Execute(IConsoleShell shell, string argStr, string[] args)
  12. {
  13. var player = shell.Player;
  14. if (player == null)
  15. {
  16. shell.WriteError(Loc.GetString("cmd-nutrition-error-player"));
  17. return;
  18. }
  19. if (player.AttachedEntity is not {Valid: true} playerEntity)
  20. {
  21. shell.WriteError(Loc.GetString("cmd-nutrition-error-entity"));
  22. return;
  23. }
  24. if (!EntityManager.TryGetComponent(playerEntity, out HungerComponent? hunger))
  25. {
  26. shell.WriteError(Loc.GetString("cmd-nutrition-error-component", ("comp", nameof(HungerComponent))));
  27. return;
  28. }
  29. var hungryThreshold = hunger.Thresholds[HungerThreshold.Starving];
  30. EntityManager.System<HungerSystem>().SetHunger(playerEntity, hungryThreshold, hunger);
  31. }
  32. }