Files
OldThink/Content.Server/Nutrition/Hungry.cs

47 lines
1.5 KiB
C#
Raw Normal View History

2020-11-10 17:06:20 +01:00
using Content.Server.Administration;
2021-06-09 22:19:39 +02:00
using Content.Server.Nutrition.Components;
2020-11-10 17:06:20 +01:00
using Content.Shared.Administration;
2021-06-09 22:19:39 +02:00
using Content.Shared.Nutrition.Components;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
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 as IPlayerSession;
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;
}
var hungryThreshold = hunger.HungerThresholds[HungerThreshold.Starving];
hunger.CurrentHunger = hungryThreshold;
}
}
}