2020-11-10 17:06:20 +01:00
|
|
|
using Content.Server.Administration;
|
|
|
|
|
using Content.Shared.Administration;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Nutrition.Components;
|
2023-04-02 22:42:30 -04:00
|
|
|
using Content.Shared.Nutrition.EntitySystems;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2020-11-02 11:37:37 +01:00
|
|
|
|
2024-08-05 01:12:07 -07:00
|
|
|
namespace Content.Server.Nutrition;
|
2021-12-05 21:02:04 +01:00
|
|
|
|
2024-08-05 01:12:07 -07:00
|
|
|
[AdminCommand(AdminFlags.Debug)]
|
|
|
|
|
public sealed class Hungry : LocalizedEntityCommands
|
|
|
|
|
{
|
|
|
|
|
public override string Command => "hungry";
|
2020-11-02 11:37:37 +01:00
|
|
|
|
2024-08-05 01:12:07 -07:00
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
|
|
|
{
|
|
|
|
|
var player = shell.Player;
|
|
|
|
|
if (player == null)
|
2020-11-02 11:37:37 +01:00
|
|
|
{
|
2024-08-05 01:12:07 -07:00
|
|
|
shell.WriteError(Loc.GetString("cmd-nutrition-error-player"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-11-02 11:37:37 +01:00
|
|
|
|
2024-08-05 01:12:07 -07:00
|
|
|
if (player.AttachedEntity is not {Valid: true} playerEntity)
|
|
|
|
|
{
|
|
|
|
|
shell.WriteError(Loc.GetString("cmd-nutrition-error-entity"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-11-02 11:37:37 +01:00
|
|
|
|
2024-08-05 01:12:07 -07:00
|
|
|
if (!EntityManager.TryGetComponent(playerEntity, out HungerComponent? hunger))
|
|
|
|
|
{
|
|
|
|
|
shell.WriteError(Loc.GetString("cmd-nutrition-error-component", ("comp", nameof(HungerComponent))));
|
|
|
|
|
return;
|
2020-11-02 11:37:37 +01:00
|
|
|
}
|
2024-08-05 01:12:07 -07:00
|
|
|
|
|
|
|
|
var hungryThreshold = hunger.Thresholds[HungerThreshold.Starving];
|
|
|
|
|
EntityManager.System<HungerSystem>().SetHunger(playerEntity, hungryThreshold, hunger);
|
2020-11-02 11:37:37 +01:00
|
|
|
}
|
|
|
|
|
}
|