Makes repairable component able to heal a set amount of damage (#6852)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Tools;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
@@ -9,6 +10,16 @@ namespace Content.Server.Repairable
|
||||
[RegisterComponent]
|
||||
public sealed class RepairableComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// All the damage to change information is stored in this <see cref="DamageSpecifier"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If this data-field is specified, it will change damage by this amount instead of setting all damage to 0.
|
||||
/// in order to heal/repair the damage values have to be negative.
|
||||
/// </remarks>
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("damage")]
|
||||
public DamageSpecifier? Damage;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)] [DataField("fuelCost")]
|
||||
public int FuelCost = 5;
|
||||
|
||||
|
||||
@@ -34,9 +34,18 @@ namespace Content.Server.Repairable
|
||||
if (!await _toolSystem.UseTool(args.Used, args.User, uid, component.FuelCost, component.DoAfterDelay, component.QualityNeeded))
|
||||
return;
|
||||
|
||||
// Repair all damage
|
||||
_damageableSystem.SetAllDamage(damageable, 0);
|
||||
_logSystem.Add(LogType.Healed, $"{ToPrettyString(args.User):user} repaired ${ToPrettyString(uid):target} back to full health");
|
||||
if (component.Damage != null)
|
||||
{
|
||||
var damageChanged = _damageableSystem.TryChangeDamage(uid, component.Damage, true, false);
|
||||
_logSystem.Add(LogType.Healed, $"{ToPrettyString(args.User):user} repaired {ToPrettyString(uid):target} by {damageChanged?.Total}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Repair all damage
|
||||
_damageableSystem.SetAllDamage(damageable, 0);
|
||||
_logSystem.Add(LogType.Healed, $"{ToPrettyString(args.User):user} repaired {ToPrettyString(uid):target} back to full health");
|
||||
}
|
||||
|
||||
|
||||
component.Owner.PopupMessage(args.User,
|
||||
Loc.GetString("comp-repairable-repair",
|
||||
|
||||
Reference in New Issue
Block a user