Rejunevate now satiates hunger and thirst plus code quality (#456)
* Change Rejunevate to satiate hunger and thirst whenever applicable * More progress * One more before rebase * Shit * Bop obsolete using * Verb will not show on non-applicable objects
This commit is contained in:
committed by
Pieter-Jan Briers
parent
421847e9d3
commit
17b31c417b
@@ -1,4 +1,4 @@
|
|||||||
using Content.Server.GameObjects;
|
using Content.Server.GlobalVerbs;
|
||||||
using Robust.Server.Interfaces.Console;
|
using Robust.Server.Interfaces.Console;
|
||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
using Robust.Shared.GameObjects;
|
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."));
|
shell.SendText(player, localizationManager.GetString("There's no entity attached to the user."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!player.AttachedEntity.TryGetComponent(out DamageableComponent damage))
|
RejuvenateVerb.PerformRejuvenate(player.AttachedEntity);
|
||||||
{
|
|
||||||
shell.SendText(player, localizationManager.GetString("The user's entity does not have a DamageableComponent."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
damage.HealAllDamage();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
@@ -56,12 +50,7 @@ namespace Content.Server.Administration
|
|||||||
shell.SendText(player, localizationManager.GetString("Could not find entity {0}", arg));
|
shell.SendText(player, localizationManager.GetString("Could not find entity {0}", arg));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!entity.TryGetComponent(out DamageableComponent damage))
|
RejuvenateVerb.PerformRejuvenate(entity);
|
||||||
{
|
|
||||||
shell.SendText(player, localizationManager.GetString("Entity {0} does not have a DamageableComponent.", arg));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
damage.HealAllDamage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,7 @@ using System.Linq;
|
|||||||
using Content.Server.Interfaces;
|
using Content.Server.Interfaces;
|
||||||
using Content.Server.Interfaces.GameObjects;
|
using Content.Server.Interfaces.GameObjects;
|
||||||
using Content.Shared.GameObjects;
|
using Content.Shared.GameObjects;
|
||||||
using Robust.Server.Console;
|
|
||||||
using Robust.Server.Interfaces.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
@@ -186,38 +182,6 @@ namespace Content.Server.GameObjects
|
|||||||
Thresholds.Add(damageType, new List<DamageThreshold>());
|
Thresholds.Add(damageType, new List<DamageThreshold>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Completely removes all damage from the DamageableComponent (heals the mob).
|
|
||||||
/// </summary>
|
|
||||||
[Verb]
|
|
||||||
private sealed class RejuvenateVerb : Verb<DamageableComponent>
|
|
||||||
{
|
|
||||||
protected override string GetText(IEntity user, DamageableComponent component) => "Rejuvenate";
|
|
||||||
|
|
||||||
protected override VerbVisibility GetVisibility(IEntity user, DamageableComponent component)
|
|
||||||
{
|
|
||||||
var groupController = IoCManager.Resolve<IConGroupController>();
|
|
||||||
|
|
||||||
if (user.TryGetComponent<IActorComponent>(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<IConGroupController>();
|
|
||||||
if (user.TryGetComponent<IActorComponent>(out var player))
|
|
||||||
{
|
|
||||||
if (groupController.CanCommand(player.playerSession, "rejuvenate"))
|
|
||||||
component.HealAllDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Server.GameObjects.Components.Mobs;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
using Content.Server.GameObjects.Components.Movement;
|
using Content.Server.GameObjects.Components.Movement;
|
||||||
@@ -164,6 +164,11 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetFood()
|
||||||
|
{
|
||||||
|
_currentHunger = HungerThresholds[HungerThreshold.Okay];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum HungerThreshold
|
public enum HungerThreshold
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Server.GameObjects.Components.Mobs;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
using Content.Server.GameObjects.Components.Movement;
|
using Content.Server.GameObjects.Components.Movement;
|
||||||
@@ -165,6 +165,11 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetThirst()
|
||||||
|
{
|
||||||
|
_currentThirst = ThirstThresholds[ThirstThreshold.Okay];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ThirstThreshold
|
public enum ThirstThreshold
|
||||||
|
|||||||
61
Content.Server/GlobalVerbs/RejuvenateVerb.cs
Normal file
61
Content.Server/GlobalVerbs/RejuvenateVerb.cs
Normal file
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Completely removes all damage from the DamageableComponent (heals the mob).
|
||||||
|
/// </summary>
|
||||||
|
[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<IConGroupController>();
|
||||||
|
|
||||||
|
if (user.TryGetComponent<IActorComponent>(out var player))
|
||||||
|
{
|
||||||
|
if (!target.HasComponent<DamageableComponent>() && !target.HasComponent<HungerComponent>() && !target.HasComponent<ThirstComponent>())
|
||||||
|
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<IConGroupController>();
|
||||||
|
if (user.TryGetComponent<IActorComponent>(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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user