diff --git a/Content.Server/Atmos/Components/BarotraumaComponent.cs b/Content.Server/Atmos/Components/BarotraumaComponent.cs index 5fbba97c85..0d0c1c89b4 100644 --- a/Content.Server/Atmos/Components/BarotraumaComponent.cs +++ b/Content.Server/Atmos/Components/BarotraumaComponent.cs @@ -1,8 +1,5 @@ using Content.Shared.Damage; using Content.Shared.FixedPoint; -using Robust.Shared.GameObjects; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.ViewVariables; namespace Content.Server.Atmos.Components { @@ -24,5 +21,11 @@ namespace Content.Server.Atmos.Components /// Used to keep track of when damage starts/stops. Useful for logs. /// public bool TakingDamage = false; + + /// + /// These are the inventory slots that are checked for pressure protection. If a slot is missing protection, no protection is applied. + /// + [DataField("protectionSlots")] + public List ProtectionSlots = new() { "head", "outerClothing" }; } } diff --git a/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs b/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs index a4e196bd20..39c19081a1 100644 --- a/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs +++ b/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs @@ -1,4 +1,3 @@ -using System; using Content.Server.Administration.Logs; using Content.Server.Atmos.Components; using Content.Shared.Alert; @@ -6,8 +5,8 @@ using Content.Shared.Atmos; using Content.Shared.Damage; using Content.Shared.Database; using Content.Shared.FixedPoint; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; +using Content.Shared.Inventory; +using Robust.Shared.Containers; namespace Content.Server.Atmos.EntitySystems { @@ -17,6 +16,7 @@ namespace Content.Server.Atmos.EntitySystems [Dependency] private readonly DamageableSystem _damageableSystem = default!; [Dependency] private readonly AlertsSystem _alertsSystem = default!; [Dependency] private readonly AdminLogSystem _logSystem = default!; + [Dependency] private readonly InventorySystem _inventorySystem = default!; private const float UpdateTimer = 1f; private float _timer; @@ -39,27 +39,72 @@ namespace Content.Server.Atmos.EntitySystems args.Multiplier *= component.LowPressureMultiplier; } - private float CalculateFeltPressure(float environmentPressure, PressureEvent pressureEvent) + public float GetFeltLowPressure(BarotraumaComponent baro, float environmentPressure) { - environmentPressure += pressureEvent.Modifier; - environmentPressure *= pressureEvent.Multiplier; - return environmentPressure; - } + var modifier = float.MaxValue; + var multiplier = float.MaxValue; - public float GetFeltLowPressure(EntityUid uid, float environmentPressure) - { + TryComp(baro.Owner, out InventoryComponent? inv); + TryComp(baro.Owner, out ContainerManagerComponent? contMan); + + // TODO: cache this & update when equipment changes? + // This continuously raises events for every player in space. + + // First, check if for protective equipment + foreach (var slot in baro.ProtectionSlots) + { + if (!_inventorySystem.TryGetSlotEntity(baro.Owner, slot, out var equipment, inv, contMan) + || ! TryComp(equipment, out PressureProtectionComponent? protection)) + { + // Missing protection, skin is exposed. + modifier = 0; + multiplier = 1; + break; + } + + modifier = Math.Min(protection.LowPressureModifier, modifier); + multiplier = Math.Min(protection.LowPressureMultiplier, multiplier); + } + + // Then apply any generic, non-clothing related modifiers. var lowPressureEvent = new LowPressureEvent(environmentPressure); - RaiseLocalEvent(uid, lowPressureEvent, false); + RaiseLocalEvent(baro.Owner, lowPressureEvent, false); - return CalculateFeltPressure(environmentPressure, lowPressureEvent); + return (environmentPressure + modifier + lowPressureEvent.Modifier) * (multiplier * lowPressureEvent.Multiplier); } - public float GetFeltHighPressure(EntityUid uid, float environmentPressure) + public float GetFeltHighPressure(BarotraumaComponent baro, float environmentPressure) { - var highPressureEvent = new HighPressureEvent(environmentPressure); - RaiseLocalEvent(uid, highPressureEvent, false); + var modifier = float.MinValue; + var multiplier = float.MinValue; - return CalculateFeltPressure(environmentPressure, highPressureEvent); + TryComp(baro.Owner, out InventoryComponent? inv); + TryComp(baro.Owner, out ContainerManagerComponent? contMan); + + // TODO: cache this & update when equipment changes? + // Not as import and as low-pressure, but probably still useful. + + // First, check if for protective equipment + foreach (var slot in baro.ProtectionSlots) + { + if (!_inventorySystem.TryGetSlotEntity(baro.Owner, slot, out var equipment, inv, contMan) + || !TryComp(equipment, out PressureProtectionComponent? protection)) + { + // Missing protection, skin is exposed. + modifier = 0; + multiplier = 1; + break; + } + + modifier = Math.Max(protection.LowPressureModifier, modifier); + multiplier = Math.Max(protection.LowPressureMultiplier, multiplier); + } + + // Then apply any generic, non-clothing related modifiers. + var highPressureEvent = new HighPressureEvent(environmentPressure); + RaiseLocalEvent(baro.Owner, highPressureEvent, false); + + return (environmentPressure + modifier + highPressureEvent.Modifier) * (multiplier * highPressureEvent.Multiplier); } public override void Update(float frameTime) @@ -94,7 +139,7 @@ namespace Content.Server.Atmos.EntitySystems { // Low pressure. case <= Atmospherics.WarningLowPressure: - pressure = GetFeltLowPressure(barotrauma.Owner, pressure); + pressure = GetFeltLowPressure(barotrauma, pressure); if (pressure > Atmospherics.WarningLowPressure) goto default; @@ -119,7 +164,7 @@ namespace Content.Server.Atmos.EntitySystems // High pressure. case >= Atmospherics.WarningHighPressure: - pressure = GetFeltHighPressure(barotrauma.Owner, pressure); + pressure = GetFeltHighPressure(barotrauma, pressure); if(pressure < Atmospherics.WarningHighPressure) goto default; diff --git a/Content.Server/Atmos/PressureEvent.cs b/Content.Server/Atmos/PressureEvent.cs index 5a9bc33221..9c0b36a281 100644 --- a/Content.Server/Atmos/PressureEvent.cs +++ b/Content.Server/Atmos/PressureEvent.cs @@ -1,9 +1,6 @@ -using Content.Shared.Inventory; -using Robust.Shared.GameObjects; - namespace Content.Server.Atmos { - public abstract class PressureEvent : EntityEventArgs, IInventoryRelayEvent + public abstract class PressureEvent : EntityEventArgs { /// /// The environment pressure. @@ -29,11 +26,6 @@ namespace Content.Server.Atmos /// public float Multiplier { get; set; } = 1f; - /// - /// The inventory slots that should be checked for pressure protecting equipment. - /// - public SlotFlags TargetSlots { get; } = ~SlotFlags.POCKET; - protected PressureEvent(float pressure) { Pressure = pressure; diff --git a/Content.Server/Inventory/ServerInventorySystem.cs b/Content.Server/Inventory/ServerInventorySystem.cs index 9adaf9fbe3..8e61bf6d54 100644 --- a/Content.Server/Inventory/ServerInventorySystem.cs +++ b/Content.Server/Inventory/ServerInventorySystem.cs @@ -15,8 +15,6 @@ namespace Content.Server.Inventory { base.Initialize(); - SubscribeLocalEvent(RelayInventoryEvent); - SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(OnUseInHand); diff --git a/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml b/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml index f1127e527d..996ddded74 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml @@ -33,7 +33,7 @@ size: 10 - type: PressureProtection highPressureMultiplier: 0.6 - lowPressureMultiplier: 10 + lowPressureMultiplier: 1000 - type: TemperatureProtection coefficient: 0.2 - type: IngestionBlocker @@ -52,8 +52,8 @@ - type: Clothing size: 15 - type: PressureProtection - highPressureMultiplier: 0.6 - lowPressureMultiplier: 10 + highPressureMultiplier: 0.3 + lowPressureMultiplier: 1000 - type: TemperatureProtection coefficient: 0.1 - type: Armor diff --git a/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml b/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml index aa7aa19690..640891a6e3 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml @@ -44,8 +44,8 @@ - state: inhand-right-unshaded shader: unshaded - type: PressureProtection - highPressureMultiplier: 0.40 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.08 + lowPressureMultiplier: 10000 - type: Armor modifiers: coefficients: @@ -67,6 +67,9 @@ sprite: Clothing/Head/Hardsuits/capspace.rsi - type: Clothing sprite: Clothing/Head/Hardsuits/capspace.rsi + - type: PressureProtection + highPressureMultiplier: 0.3 + lowPressureMultiplier: 1000 - type: entity parent: HatBase @@ -78,6 +81,9 @@ sprite: Clothing/Head/Hardsuits/deathsquad.rsi - type: Clothing sprite: Clothing/Head/Hardsuits/deathsquad.rsi + - type: PressureProtection + highPressureMultiplier: 0.27 + lowPressureMultiplier: 1000 - type: entity parent: ClothingHeadHardsuitWithLightBase @@ -90,8 +96,8 @@ - type: Clothing sprite: Clothing/Head/Hardsuits/engineering.rsi - type: PressureProtection - highPressureMultiplier: 0.40 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.26 + lowPressureMultiplier: 1000 - type: entity parent: ClothingHeadHardsuitWithLightBase @@ -103,6 +109,9 @@ sprite: Clothing/Head/Hardsuits/engineering-white.rsi - type: Clothing sprite: Clothing/Head/Hardsuits/engineering-white.rsi + - type: PressureProtection + highPressureMultiplier: 0.24 + lowPressureMultiplier: 1000 - type: entity parent: HatBase @@ -115,8 +124,8 @@ - type: Clothing sprite: Clothing/Head/Hardsuits/ihsvoid.rsi - type: PressureProtection - highPressureMultiplier: 0.60 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.3 + lowPressureMultiplier: 10000 - type: entity parent: ClothingHeadHardsuitWithLightBase @@ -129,8 +138,8 @@ - type: Clothing sprite: Clothing/Head/Hardsuits/medical.rsi - type: PressureProtection - highPressureMultiplier: 0.80 - lowPressureMultiplier: 55 + highPressureMultiplier: 0.6 + lowPressureMultiplier: 5500 - type: DiseaseProtection protection: 0.15 @@ -145,8 +154,8 @@ - type: Clothing sprite: Clothing/Head/Hardsuits/rd.rsi - type: PressureProtection - highPressureMultiplier: 0.80 - lowPressureMultiplier: 55 + highPressureMultiplier: 0.60 + lowPressureMultiplier: 5500 - type: entity parent: ClothingHeadHardsuitWithLightBase @@ -159,8 +168,8 @@ - type: Clothing sprite: Clothing/Head/Hardsuits/salvage.rsi - type: PressureProtection - highPressureMultiplier: 0.70 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.525 + lowPressureMultiplier: 10000 - type: entity parent: ClothingHeadHardsuitWithLightBase @@ -173,8 +182,8 @@ - type: Clothing sprite: Clothing/Head/Hardsuits/security.rsi - type: PressureProtection - highPressureMultiplier: 0.70 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.525 + lowPressureMultiplier: 10000 - type: entity parent: ClothingHeadHardsuitWithLightBase @@ -187,8 +196,8 @@ - type: Clothing sprite: Clothing/Head/Hardsuits/security-red.rsi - type: PressureProtection - highPressureMultiplier: 0.60 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.45 + lowPressureMultiplier: 10000 - type: entity parent: ClothingHeadHardsuitWithLightBase @@ -202,6 +211,9 @@ sprite: Clothing/Head/Hardsuits/syndicate.rsi - type: PointLight color: green + - type: PressureProtection + highPressureMultiplier: 0.27 + lowPressureMultiplier: 1000 - type: entity parent: ClothingHeadHardsuitWithLightBase @@ -213,6 +225,9 @@ sprite: Clothing/Head/Hardsuits/wizard.rsi - type: Clothing sprite: Clothing/Head/Hardsuits/wizard.rsi + - type: PressureProtection + highPressureMultiplier: 0.27 + lowPressureMultiplier: 1000 - type: entity parent: ClothingHeadHardsuitBase @@ -225,8 +240,8 @@ - type: Clothing sprite: Clothing/Head/Hardsuits/lingspacehelmet.rsi - type: PressureProtection - highPressureMultiplier: 0.5 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.225 + lowPressureMultiplier: 10000 - type: entity parent: ClothingHeadHardsuitWithLightBase @@ -274,5 +289,5 @@ - state: inhand-right-unshaded shader: unshaded - type: PressureProtection - highPressureMultiplier: 0.8 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.72 + lowPressureMultiplier: 10000 diff --git a/Resources/Prototypes/Entities/Clothing/Head/helmets.yml b/Resources/Prototypes/Entities/Clothing/Head/helmets.yml index fc39ef66db..65a4019217 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/helmets.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/helmets.yml @@ -202,6 +202,9 @@ Piercing: 0.95 Heat: 0.65 Radiation: 1 + - type: PressureProtection + highPressureMultiplier: 0.65 + lowPressureMultiplier: 25 - type: entity parent: ClothingHeadHardsuitWithLightBase # hardsuitlight base for light and protection @@ -224,6 +227,9 @@ Piercing: 0.95 Heat: 0.5 Radiation: .95 + - type: PressureProtection + highPressureMultiplier: 0.45 + lowPressureMultiplier: 25 - type: entity parent: ClothingHeadBase diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml index 1700e67a1f..d27a3b70d2 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml @@ -16,8 +16,8 @@ name: base hardsuit components: - type: PressureProtection - highPressureMultiplier: 0.5 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.3 + lowPressureMultiplier: 1000 - type: TemperatureProtection coefficient: 0.001 # yes it needs to be this low, fires are fucking deadly apparently!!!! - type: ClothingSpeedModifier @@ -42,8 +42,8 @@ name: base EVA Suit components: - type: PressureProtection - highPressureMultiplier: 1 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.6 + lowPressureMultiplier: 1000 - type: TemperatureProtection coefficient: 0.01 # Not complete protection from fire - type: ClothingSpeedModifier diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml index c7888c27c7..ecd931cdae 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml @@ -9,8 +9,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/atmospherics.rsi - type: PressureProtection - highPressureMultiplier: 0.2 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.08 + lowPressureMultiplier: 10000 - type: ClothingSpeedModifier walkModifier: 0.65 sprintModifier: 0.7 @@ -36,8 +36,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/capspace.rsi - type: PressureProtection - highPressureMultiplier: 0.5 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.3 + lowPressureMultiplier: 1000 - type: ClothingSpeedModifier walkModifier: 0.8 sprintModifier: 0.8 @@ -61,8 +61,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/deathsquad.rsi - type: PressureProtection - highPressureMultiplier: 0.45 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.27 + lowPressureMultiplier: 1000 - type: ClothingSpeedModifier walkModifier: 1.0 sprintModifier: 1.0 @@ -86,8 +86,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/engineering.rsi - type: PressureProtection - highPressureMultiplier: 0.65 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.26 + lowPressureMultiplier: 1000 - type: ClothingSpeedModifier walkModifier: 0.65 sprintModifier: 0.65 @@ -111,8 +111,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/engineering-white.rsi - type: PressureProtection - highPressureMultiplier: 0.4 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.24 + lowPressureMultiplier: 1000 - type: ClothingSpeedModifier walkModifier: 0.75 sprintModifier: 0.8 @@ -136,10 +136,12 @@ sprite: Clothing/OuterClothing/Hardsuits/ihsvoid.rsi - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/ihsvoid.rsi - - type: PressureProtection - type: ClothingSpeedModifier walkModifier: 0.8 sprintModifier: 0.8 + - type: PressureProtection + highPressureMultiplier: 0.3 + lowPressureMultiplier: 10000 - type: entity parent: ClothingOuterEVASuitBase @@ -187,8 +189,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/medical.rsi - type: PressureProtection - highPressureMultiplier: 0.75 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.6 + lowPressureMultiplier: 5500 - type: DiseaseProtection protection: 0.2 - type: ClothingSpeedModifier @@ -211,8 +213,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/rd.rsi - type: PressureProtection - highPressureMultiplier: 0.75 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.60 + lowPressureMultiplier: 5500 - type: Armor modifiers: coefficients: @@ -236,8 +238,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/salvage.rsi - type: PressureProtection - highPressureMultiplier: 0.75 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.525 + lowPressureMultiplier: 10000 - type: ClothingSpeedModifier walkModifier: 0.6 #changing these values around so its only a tiny bit faster so less salvages get stuck floating in space sprintModifier: 0.65 @@ -261,8 +263,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/security.rsi - type: PressureProtection - highPressureMultiplier: 0.75 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.525 + lowPressureMultiplier: 10000 - type: Armor modifiers: coefficients: @@ -283,8 +285,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/security-red.rsi - type: PressureProtection - highPressureMultiplier: 0.75 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.45 + lowPressureMultiplier: 10000 - type: ClothingSpeedModifier walkModifier: 0.7 sprintModifier: 0.7 @@ -308,8 +310,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/syndicate.rsi - type: PressureProtection - highPressureMultiplier: 0.45 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.27 + lowPressureMultiplier: 1000 - type: ClothingSpeedModifier walkModifier: 1.0 sprintModifier: 1.0 @@ -333,8 +335,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/wizard.rsi - type: PressureProtection - highPressureMultiplier: 0.45 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.27 + lowPressureMultiplier: 1000 - type: ClothingSpeedModifier walkModifier: 0.8 sprintModifier: 0.8 @@ -358,8 +360,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/lingspacesuit.rsi - type: PressureProtection - highPressureMultiplier: 0.45 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.225 + lowPressureMultiplier: 10000 - type: ClothingSpeedModifier walkModifier: .8 sprintModifier: .8 @@ -383,8 +385,8 @@ - type: Clothing sprite: Clothing/OuterClothing/Hardsuits/spatio.rsi - type: PressureProtection - highPressureMultiplier: 0.9 - lowPressureMultiplier: 100 + highPressureMultiplier: 0.72 + lowPressureMultiplier: 10000 - type: ClothingSpeedModifier walkModifier: 0.9 #mildly better than eva, might adjust this down if its heavily abused but want to see how it plays out in game first sprintModifier: 0.8