Files

44 lines
1.5 KiB
C#
Raw Permalink Normal View History

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;
using Robust.Shared.Console;
2021-06-09 22:19:39 +02:00
namespace Content.Server.Nutrition
{
2020-11-10 17:06:20 +01:00
[AdminCommand(AdminFlags.Debug)]
public sealed class Hungry : IConsoleCommand
{
2021-12-05 21:02:04 +01:00
[Dependency] private readonly IEntityManager _entities = default!;
public string Command => "hungry";
public string Description => "Makes you hungry.";
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player;
if (player == null)
{
shell.WriteLine("You cannot use this command unless you are a player.");
return;
}
2021-12-05 21:02:04 +01:00
if (player.AttachedEntity is not {Valid: true} playerEntity)
{
shell.WriteLine("You cannot use this command without an entity.");
return;
}
2021-12-05 21:02:04 +01:00
if (!_entities.TryGetComponent(playerEntity, out HungerComponent? hunger))
{
shell.WriteLine($"Your entity does not have a {nameof(HungerComponent)} component.");
return;
}
2023-04-02 22:42:30 -04:00
var hungryThreshold = hunger.Thresholds[HungerThreshold.Starving];
_entities.System<HungerSystem>().SetHunger(playerEntity, hungryThreshold, hunger);
}
}
}