Support multiple containers for HealingComponent (#16867)

This commit is contained in:
Vordenburg
2023-06-03 15:30:20 -04:00
committed by GitHub
parent d8c05d013e
commit 49ba959b82
4 changed files with 23 additions and 12 deletions

View File

@@ -1,8 +1,7 @@
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes; using Content.Shared.Damage.Prototypes;
using Content.Shared.DoAfter;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Server.Medical.Components namespace Content.Server.Medical.Components
{ {
@@ -36,8 +35,8 @@ namespace Content.Server.Medical.Components
/// HealingComponent this filters what damage container type this component should work on. If null, /// HealingComponent this filters what damage container type this component should work on. If null,
/// all damage container types are supported. /// all damage container types are supported.
/// </remarks> /// </remarks>
[DataField("damageContainer", customTypeSerializer: typeof(PrototypeIdSerializer<DamageContainerPrototype>))] [DataField("damageContainers", customTypeSerializer: typeof(PrototypeIdListSerializer<DamageContainerPrototype>))]
public string? DamageContainerID; public List<string>? DamageContainers;
/// <summary> /// <summary>
/// How long it takes to apply the damage. /// How long it takes to apply the damage.

View File

@@ -51,8 +51,12 @@ public sealed class HealingSystem : EntitySystem
if (args.Handled || args.Cancelled) if (args.Handled || args.Cancelled)
return; return;
if (component.DamageContainerID is not null && !component.DamageContainerID.Equals(component.DamageContainerID)) if (healing.DamageContainers is not null &&
component.DamageContainerID is not null &&
!healing.DamageContainers.Contains(component.DamageContainerID))
{
return; return;
}
// Heal some bloodloss damage. // Heal some bloodloss damage.
if (healing.BloodlossModifier != 0) if (healing.BloodlossModifier != 0)
@@ -140,9 +144,12 @@ public sealed class HealingSystem : EntitySystem
if (!TryComp<DamageableComponent>(target, out var targetDamage)) if (!TryComp<DamageableComponent>(target, out var targetDamage))
return false; return false;
if (component.DamageContainerID is not null && if (component.DamageContainers is not null &&
!component.DamageContainerID.Equals(targetDamage.DamageContainerID)) targetDamage.DamageContainerID is not null &&
!component.DamageContainers.Contains(targetDamage.DamageContainerID))
{
return false; return false;
}
if (user != target && !_interactionSystem.InRangeUnobstructed(user, target, popup: true)) if (user != target && !_interactionSystem.InRangeUnobstructed(user, target, popup: true))
return false; return false;

View File

@@ -71,7 +71,8 @@
- DroneUsable - DroneUsable
- Gauze - Gauze
- type: Healing - type: Healing
damageContainer: Biological damageContainers:
- Biological
damage: damage:
types: types:
Slash: -0.5 Slash: -0.5

View File

@@ -26,7 +26,8 @@
- type: Item - type: Item
heldPrefix: ointment heldPrefix: ointment
- type: Healing - type: Healing
damageContainer: Biological damageContainers:
- Biological
damage: damage:
types: types:
Heat: -5 Heat: -5
@@ -63,7 +64,8 @@
- type: Sprite - type: Sprite
state: brutepack state: brutepack
- type: Healing - type: Healing
damageContainer: Biological damageContainers:
- Biological
damage: damage:
groups: groups:
Brute: -15 # 5 for each type in the group Brute: -15 # 5 for each type in the group
@@ -97,7 +99,8 @@
- type: Sprite - type: Sprite
state: bloodpack state: bloodpack
- type: Healing - type: Healing
damageContainer: Biological damageContainers:
- Biological
damage: damage:
types: types:
Bloodloss: -0.5 #lowers bloodloss damage Bloodloss: -0.5 #lowers bloodloss damage
@@ -127,7 +130,8 @@
graph: Gauze graph: Gauze
node: gauze node: gauze
- type: Healing - type: Healing
damageContainer: Biological damageContainers:
- Biological
damage: damage:
types: types:
Slash: -2.5 Slash: -2.5