using Content.Server.Atmos.Components; using Content.Server.Atmos.EntitySystems; using Content.Server.Nutrition.Components; using Content.Server.Nutrition.EntitySystems; using Content.Shared.Administration; using Content.Shared.Damage; using Content.Shared.Jittering; using Content.Shared.MobState.Components; using Content.Shared.Nutrition.Components; using Content.Shared.StatusEffect; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; namespace Content.Server.Administration.Commands { [AdminCommand(AdminFlags.Admin)] public class RejuvenateCommand : IConsoleCommand { public string Command => "rejuvenate"; public string Description => Loc.GetString("rejuvenate-command-description"); public string Help => Loc.GetString("rejuvenate-command-help-text"); public void Execute(IConsoleShell shell, string argStr, string[] args) { var player = shell.Player as IPlayerSession; if (args.Length < 1 && player != null) //Try to heal the users mob if applicable { shell.WriteLine(Loc.GetString("rejuvenate-command-self-heal-message")); if (player.AttachedEntity == null) { shell.WriteLine(Loc.GetString("rejuvenate-command-no-entity-attached-message")); return; } PerformRejuvenate(player.AttachedEntity); } var entityManager = IoCManager.Resolve(); foreach (var arg in args) { if(!EntityUid.TryParse(arg, out var uid) || !entityManager.TryGetEntity(uid, out var entity)) { shell.WriteLine(Loc.GetString("shell-could-not-find-entity",("entity", arg))); continue; } PerformRejuvenate(entity); } } public static void PerformRejuvenate(IEntity target) { target.GetComponentOrNull()?.UpdateState(0); target.GetComponentOrNull()?.ResetFood(); target.GetComponentOrNull()?.ResetThirst(); EntitySystem.Get().TryRemoveAllStatusEffects(target.Uid); if (target.TryGetComponent(out FlammableComponent? flammable)) { EntitySystem.Get().Extinguish(target.Uid, flammable); } if (target.TryGetComponent(out DamageableComponent? damageable)) { EntitySystem.Get().SetAllDamage(damageable, 0); } if (target.TryGetComponent(out CreamPiedComponent? creamPied)) { EntitySystem.Get().SetCreamPied(target.Uid, creamPied, false); } if (target.HasComponent()) { IoCManager.Resolve().RemoveComponent(target.Uid); } } } }