From 6c1ba187e37171f90b3521f4c26b2baa3d0b2255 Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Sat, 23 Oct 2021 11:45:57 -0700 Subject: [PATCH] Add maximum to barotrauma damage (#4989) --- .../Atmos/Components/BarotraumaComponent.cs | 4 ++++ .../Atmos/EntitySystems/BarotraumaSystem.cs | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Content.Server/Atmos/Components/BarotraumaComponent.cs b/Content.Server/Atmos/Components/BarotraumaComponent.cs index 9452ccd29f..15226fc5eb 100644 --- a/Content.Server/Atmos/Components/BarotraumaComponent.cs +++ b/Content.Server/Atmos/Components/BarotraumaComponent.cs @@ -16,5 +16,9 @@ namespace Content.Server.Atmos.Components [DataField("damage", required: true)] [ViewVariables(VVAccess.ReadWrite)] public DamageSpecifier Damage = default!; + + [DataField("maxDamage")] + [ViewVariables(VVAccess.ReadWrite)] + public int MaxDamage = 200; } } diff --git a/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs b/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs index f72be55441..6259abdf7c 100644 --- a/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs +++ b/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs @@ -1,4 +1,5 @@ using System; +using System.Data; using Content.Server.Alert; using Content.Server.Atmos.Components; using Content.Shared.Alert; @@ -68,8 +69,16 @@ namespace Content.Server.Atmos.EntitySystems _timer -= UpdateTimer; - foreach (var (barotrauma, transform) in EntityManager.EntityQuery()) + foreach (var (barotrauma, damageable, transform) in EntityManager.EntityQuery()) { + var totalDamage = 0; + foreach (var (barotraumaDamageType, _) in barotrauma.Damage.DamageDict) + { + totalDamage += damageable.Damage.DamageDict[barotraumaDamageType]; + } + if (totalDamage > barotrauma.MaxDamage) + continue; + var uid = barotrauma.Owner.Uid; var status = barotrauma.Owner.GetComponentOrNull();