2021-10-05 14:29:03 +11:00
|
|
|
using Content.Server.Atmos.Components;
|
|
|
|
|
using Content.Server.Atmos.EntitySystems;
|
|
|
|
|
using Content.Server.Nutrition.Components;
|
|
|
|
|
using Content.Server.Nutrition.EntitySystems;
|
2020-10-30 16:06:48 +01:00
|
|
|
using Content.Shared.Administration;
|
2021-10-05 14:29:03 +11:00
|
|
|
using Content.Shared.Damage;
|
2021-10-09 17:30:04 +02:00
|
|
|
using Content.Shared.Jittering;
|
2021-11-08 15:11:58 +01:00
|
|
|
using Content.Shared.MobState.Components;
|
2021-10-05 14:29:03 +11:00
|
|
|
using Content.Shared.Nutrition.Components;
|
2021-10-15 14:45:04 -07:00
|
|
|
using Content.Shared.StatusEffect;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Server.Player;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2019-10-13 09:30:44 -04:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Localization;
|
|
|
|
|
|
2020-10-30 16:06:48 +01:00
|
|
|
namespace Content.Server.Administration.Commands
|
2019-10-13 09:30:44 -04:00
|
|
|
{
|
2020-10-30 16:06:48 +01:00
|
|
|
[AdminCommand(AdminFlags.Admin)]
|
2021-10-05 14:29:03 +11:00
|
|
|
public class RejuvenateCommand : IConsoleCommand
|
2019-10-13 09:30:44 -04:00
|
|
|
{
|
|
|
|
|
public string Command => "rejuvenate";
|
2021-06-21 02:13:54 +02:00
|
|
|
|
|
|
|
|
public string Description => Loc.GetString("rejuvenate-command-description");
|
|
|
|
|
|
|
|
|
|
public string Help => Loc.GetString("rejuvenate-command-help-text");
|
2019-10-13 09:30:44 -04:00
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2019-10-13 09:30:44 -04:00
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
var player = shell.Player as IPlayerSession;
|
2019-10-13 09:30:44 -04:00
|
|
|
if (args.Length < 1 && player != null) //Try to heal the users mob if applicable
|
|
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
shell.WriteLine(Loc.GetString("rejuvenate-command-self-heal-message"));
|
2019-10-13 09:30:44 -04:00
|
|
|
if (player.AttachedEntity == null)
|
|
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
shell.WriteLine(Loc.GetString("rejuvenate-command-no-entity-attached-message"));
|
2019-10-13 09:30:44 -04:00
|
|
|
return;
|
|
|
|
|
}
|
2021-10-05 14:29:03 +11:00
|
|
|
PerformRejuvenate(player.AttachedEntity);
|
2019-10-13 09:30:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
foreach (var arg in args)
|
|
|
|
|
{
|
|
|
|
|
if(!EntityUid.TryParse(arg, out var uid) || !entityManager.TryGetEntity(uid, out var entity))
|
|
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
shell.WriteLine(Loc.GetString("shell-could-not-find-entity",("entity", arg)));
|
2019-10-13 09:30:44 -04:00
|
|
|
continue;
|
|
|
|
|
}
|
2021-10-05 14:29:03 +11:00
|
|
|
PerformRejuvenate(entity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void PerformRejuvenate(IEntity target)
|
|
|
|
|
{
|
2021-11-08 15:11:58 +01:00
|
|
|
target.GetComponentOrNull<MobStateComponent>()?.UpdateState(0);
|
2021-10-05 14:29:03 +11:00
|
|
|
target.GetComponentOrNull<HungerComponent>()?.ResetFood();
|
|
|
|
|
target.GetComponentOrNull<ThirstComponent>()?.ResetThirst();
|
2021-10-10 12:47:26 +02:00
|
|
|
|
2021-10-15 14:45:04 -07:00
|
|
|
EntitySystem.Get<StatusEffectsSystem>().TryRemoveAllStatusEffects(target.Uid);
|
2021-10-05 14:29:03 +11:00
|
|
|
|
2021-10-05 11:14:44 +02:00
|
|
|
if (target.TryGetComponent(out FlammableComponent? flammable))
|
|
|
|
|
{
|
|
|
|
|
EntitySystem.Get<FlammableSystem>().Extinguish(target.Uid, flammable);
|
|
|
|
|
}
|
2021-10-05 14:29:03 +11:00
|
|
|
|
|
|
|
|
if (target.TryGetComponent(out DamageableComponent? damageable))
|
|
|
|
|
{
|
|
|
|
|
EntitySystem.Get<DamageableSystem>().SetAllDamage(damageable, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (target.TryGetComponent(out CreamPiedComponent? creamPied))
|
|
|
|
|
{
|
|
|
|
|
EntitySystem.Get<CreamPieSystem>().SetCreamPied(target.Uid, creamPied, false);
|
2019-10-13 09:30:44 -04:00
|
|
|
}
|
2021-10-09 17:30:04 +02:00
|
|
|
|
|
|
|
|
if (target.HasComponent<JitteringComponent>())
|
|
|
|
|
{
|
|
|
|
|
target.RemoveComponent<JitteringComponent>();
|
|
|
|
|
}
|
2019-10-13 09:30:44 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|