diff --git a/Content.Server/Administration/Rejuvenate.cs b/Content.Server/Administration/Rejuvenate.cs index 7b372a3bd1..8439e634d5 100644 --- a/Content.Server/Administration/Rejuvenate.cs +++ b/Content.Server/Administration/Rejuvenate.cs @@ -1,4 +1,4 @@ -using Content.Server.GameObjects; +using Content.Server.GlobalVerbs; using Robust.Server.Interfaces.Console; using Robust.Server.Interfaces.Player; using Robust.Shared.GameObjects; @@ -39,13 +39,7 @@ namespace Content.Server.Administration shell.SendText(player, localizationManager.GetString("There's no entity attached to the user.")); return; } - if (!player.AttachedEntity.TryGetComponent(out DamageableComponent damage)) - { - shell.SendText(player, localizationManager.GetString("The user's entity does not have a DamageableComponent.")); - return; - } - damage.HealAllDamage(); - return; + RejuvenateVerb.PerformRejuvenate(player.AttachedEntity); } var entityManager = IoCManager.Resolve(); @@ -56,12 +50,7 @@ namespace Content.Server.Administration shell.SendText(player, localizationManager.GetString("Could not find entity {0}", arg)); continue; } - if (!entity.TryGetComponent(out DamageableComponent damage)) - { - shell.SendText(player, localizationManager.GetString("Entity {0} does not have a DamageableComponent.", arg)); - continue; - } - damage.HealAllDamage(); + RejuvenateVerb.PerformRejuvenate(entity); } } } diff --git a/Content.Server/GameObjects/Components/Damage/DamageableComponent.cs b/Content.Server/GameObjects/Components/Damage/DamageableComponent.cs index 1b4f900872..a933884708 100644 --- a/Content.Server/GameObjects/Components/Damage/DamageableComponent.cs +++ b/Content.Server/GameObjects/Components/Damage/DamageableComponent.cs @@ -4,11 +4,7 @@ using System.Linq; using Content.Server.Interfaces; using Content.Server.Interfaces.GameObjects; using Content.Shared.GameObjects; -using Robust.Server.Console; -using Robust.Server.Interfaces.GameObjects; using Robust.Shared.GameObjects; -using Robust.Shared.Interfaces.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; @@ -186,38 +182,6 @@ namespace Content.Server.GameObjects Thresholds.Add(damageType, new List()); } } - - /// - /// Completely removes all damage from the DamageableComponent (heals the mob). - /// - [Verb] - private sealed class RejuvenateVerb : Verb - { - protected override string GetText(IEntity user, DamageableComponent component) => "Rejuvenate"; - - protected override VerbVisibility GetVisibility(IEntity user, DamageableComponent component) - { - var groupController = IoCManager.Resolve(); - - if (user.TryGetComponent(out var player)) - { - if (groupController.CanCommand(player.playerSession, "rejuvenate")) - return VerbVisibility.Visible; - } - return VerbVisibility.Invisible; - } - - protected override void Activate(IEntity user, DamageableComponent component) - { - var groupController = IoCManager.Resolve(); - if (user.TryGetComponent(out var player)) - { - if (groupController.CanCommand(player.playerSession, "rejuvenate")) - component.HealAllDamage(); - } - - } - } } } diff --git a/Content.Server/GameObjects/Components/Nutrition/HungerComponent.cs b/Content.Server/GameObjects/Components/Nutrition/HungerComponent.cs index 364ef8d438..1b3d3cb21f 100644 --- a/Content.Server/GameObjects/Components/Nutrition/HungerComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/HungerComponent.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Movement; @@ -164,6 +164,11 @@ namespace Content.Server.GameObjects.Components.Nutrition return; } } + + public void ResetFood() + { + _currentHunger = HungerThresholds[HungerThreshold.Okay]; + } } public enum HungerThreshold diff --git a/Content.Server/GameObjects/Components/Nutrition/ThirstComponent.cs b/Content.Server/GameObjects/Components/Nutrition/ThirstComponent.cs index cef1be09f5..76b7acf34e 100644 --- a/Content.Server/GameObjects/Components/Nutrition/ThirstComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/ThirstComponent.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Movement; @@ -165,6 +165,11 @@ namespace Content.Server.GameObjects.Components.Nutrition return; } } + + public void ResetThirst() + { + _currentThirst = ThirstThresholds[ThirstThreshold.Okay]; + } } public enum ThirstThreshold diff --git a/Content.Server/GlobalVerbs/RejuvenateVerb.cs b/Content.Server/GlobalVerbs/RejuvenateVerb.cs new file mode 100644 index 0000000000..d5511bf0a7 --- /dev/null +++ b/Content.Server/GlobalVerbs/RejuvenateVerb.cs @@ -0,0 +1,61 @@ +using Content.Server.GameObjects; +using Content.Server.GameObjects.Components.Nutrition; +using Content.Shared.GameObjects; +using Robust.Server.Console; +using Robust.Server.Interfaces.GameObjects; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.IoC; + +namespace Content.Server.GlobalVerbs +{ + /// + /// Completely removes all damage from the DamageableComponent (heals the mob). + /// + [GlobalVerb] + class RejuvenateVerb : GlobalVerb + { + public override string GetText(IEntity user, IEntity target) => "Rejuvenate"; + public override bool RequireInteractionRange => false; + + public override VerbVisibility GetVisibility(IEntity user, IEntity target) + { + var groupController = IoCManager.Resolve(); + + if (user.TryGetComponent(out var player)) + { + if (!target.HasComponent() && !target.HasComponent() && !target.HasComponent()) + return VerbVisibility.Invisible; + + if (groupController.CanCommand(player.playerSession, "rejuvenate")) + return VerbVisibility.Visible; + } + return VerbVisibility.Invisible; + } + + public override void Activate(IEntity user, IEntity target) + { + var groupController = IoCManager.Resolve(); + if (user.TryGetComponent(out var player)) + { + if (groupController.CanCommand(player.playerSession, "rejuvenate")) + PerformRejuvenate(target); + } + + } + public static void PerformRejuvenate(IEntity target) + { + if (target.TryGetComponent(out DamageableComponent damage)) + { + damage.HealAllDamage(); + } + if (target.TryGetComponent(out HungerComponent hunger)) + { + hunger.ResetFood(); + } + if (target.TryGetComponent(out ThirstComponent thirst)) + { + thirst.ResetThirst(); + } + } + } +}