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