From 91292522b504b82187846e72a5d3d086a533cf7a Mon Sep 17 00:00:00 2001
From: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
Date: Mon, 27 Oct 2025 04:00:37 -0700
Subject: [PATCH] DeltaPressure Predicted Examine (#41135)
* predicted examine
* atrociously satanic
* do it right this time
* deltafields aren't necessary
* Update Content.Server/Atmos/EntitySystems/AtmosphereSystem.DeltaPressure.cs
---------
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
---
.../EntitySystems/DeltaPressureSystem.cs | 5 +++++
.../Tests/Atmos/DeltaPressureTest.cs | 1 +
.../Components/GridAtmosphereComponent.cs | 1 +
.../AtmosphereSystem.DeltaPressure.cs | 20 ++++++++++++++++---
.../EntitySystems/DeltaPressureSystem.cs | 14 +++----------
.../Components/DeltaPressureComponent.cs | 20 +++++++++----------
.../SharedDeltaPressureSystem.cs | 20 +++++++++++++++++++
7 files changed, 57 insertions(+), 24 deletions(-)
create mode 100644 Content.Client/Atmos/EntitySystems/DeltaPressureSystem.cs
rename {Content.Server => Content.Shared}/Atmos/Components/DeltaPressureComponent.cs (89%)
create mode 100644 Content.Shared/Atmos/EntitySystems/SharedDeltaPressureSystem.cs
diff --git a/Content.Client/Atmos/EntitySystems/DeltaPressureSystem.cs b/Content.Client/Atmos/EntitySystems/DeltaPressureSystem.cs
new file mode 100644
index 0000000000..3d9893ac62
--- /dev/null
+++ b/Content.Client/Atmos/EntitySystems/DeltaPressureSystem.cs
@@ -0,0 +1,5 @@
+using Content.Shared.Atmos.EntitySystems;
+
+namespace Content.Client.Atmos.EntitySystems;
+
+public sealed class DeltaPressureSystem : SharedDeltaPressureSystem;
diff --git a/Content.IntegrationTests/Tests/Atmos/DeltaPressureTest.cs b/Content.IntegrationTests/Tests/Atmos/DeltaPressureTest.cs
index 839e0ea897..c3b3877c98 100644
--- a/Content.IntegrationTests/Tests/Atmos/DeltaPressureTest.cs
+++ b/Content.IntegrationTests/Tests/Atmos/DeltaPressureTest.cs
@@ -4,6 +4,7 @@ using Content.Server.Atmos;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
+using Content.Shared.Atmos.Components;
using Robust.Shared.EntitySerialization;
using Robust.Shared.EntitySerialization.Systems;
using Robust.Shared.GameObjects;
diff --git a/Content.Server/Atmos/Components/GridAtmosphereComponent.cs b/Content.Server/Atmos/Components/GridAtmosphereComponent.cs
index 2d36d2bd14..2a0d87515c 100644
--- a/Content.Server/Atmos/Components/GridAtmosphereComponent.cs
+++ b/Content.Server/Atmos/Components/GridAtmosphereComponent.cs
@@ -3,6 +3,7 @@ using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Piping.Components;
using Content.Server.Atmos.Serialization;
using Content.Server.NodeContainer.NodeGroups;
+using Content.Shared.Atmos.Components;
namespace Content.Server.Atmos.Components
{
diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.DeltaPressure.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.DeltaPressure.cs
index efddcaf1a7..255e58dcbf 100644
--- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.DeltaPressure.cs
+++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.DeltaPressure.cs
@@ -1,5 +1,6 @@
using Content.Server.Atmos.Components;
using Content.Shared.Atmos;
+using Content.Shared.Atmos.Components;
using Content.Shared.Damage;
using Robust.Shared.Random;
using Robust.Shared.Threading;
@@ -175,7 +176,7 @@ public sealed partial class AtmosphereSystem
/// containing the queue.
/// The current absolute pressure being experienced by the entity.
/// The current delta pressure being experienced by the entity.
- private static void EnqueueDeltaPressureDamage(Entity ent,
+ private void EnqueueDeltaPressureDamage(Entity ent,
GridAtmosphereComponent gridAtmosComp,
float pressure,
float delta)
@@ -184,7 +185,7 @@ public sealed partial class AtmosphereSystem
var aboveMinDeltaPressure = delta > ent.Comp.MinPressureDelta;
if (!aboveMinPressure && !aboveMinDeltaPressure)
{
- ent.Comp.IsTakingDamage = false;
+ SetIsTakingDamageState(ent, false);
return;
}
@@ -251,7 +252,20 @@ public sealed partial class AtmosphereSystem
var appliedDamage = ScaleDamage(ent, ent.Comp.BaseDamage, maxPressureCapped);
_damage.TryChangeDamage(ent, appliedDamage, ignoreResistances: true, interruptsDoAfters: false);
- ent.Comp.IsTakingDamage = true;
+ SetIsTakingDamageState(ent, true);
+ }
+
+ ///
+ /// Helper function to prevent spamming clients with dirty events when the damage state hasn't changed.
+ ///
+ /// The entity to check.
+ /// The value to set.
+ private void SetIsTakingDamageState(Entity ent, bool toSet)
+ {
+ if (ent.Comp.IsTakingDamage == toSet)
+ return;
+ ent.Comp.IsTakingDamage = toSet;
+ Dirty(ent);
}
///
diff --git a/Content.Server/Atmos/EntitySystems/DeltaPressureSystem.cs b/Content.Server/Atmos/EntitySystems/DeltaPressureSystem.cs
index dd7091c270..669735b90d 100644
--- a/Content.Server/Atmos/EntitySystems/DeltaPressureSystem.cs
+++ b/Content.Server/Atmos/EntitySystems/DeltaPressureSystem.cs
@@ -1,6 +1,6 @@
using Content.Server.Atmos.Components;
-using Content.Shared.Examine;
-using Robust.Shared.Map.Components;
+using Content.Shared.Atmos.Components;
+using Content.Shared.Atmos.EntitySystems;
namespace Content.Server.Atmos.EntitySystems;
@@ -14,7 +14,7 @@ namespace Content.Server.Atmos.EntitySystems;
/// This system handles the adding and removing of entities to a processing list,
/// as well as any field changes via the API.
///
-public sealed class DeltaPressureSystem : EntitySystem
+public sealed partial class DeltaPressureSystem : SharedDeltaPressureSystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
@@ -24,8 +24,6 @@ public sealed class DeltaPressureSystem : EntitySystem
SubscribeLocalEvent(OnComponentInit);
SubscribeLocalEvent(OnComponentShutdown);
- SubscribeLocalEvent(OnExamined);
-
SubscribeLocalEvent(OnGridChanged);
}
@@ -48,12 +46,6 @@ public sealed class DeltaPressureSystem : EntitySystem
_atmosphereSystem.TryRemoveDeltaPressureEntity(ent.Comp.GridUid.Value, ent);
}
- private void OnExamined(Entity ent, ref ExaminedEvent args)
- {
- if (ent.Comp.IsTakingDamage)
- args.PushMarkup(Loc.GetString("window-taking-damage"));
- }
-
private void OnGridChanged(Entity ent, ref GridUidChangedEvent args)
{
if (args.OldGrid != null)
diff --git a/Content.Server/Atmos/Components/DeltaPressureComponent.cs b/Content.Shared/Atmos/Components/DeltaPressureComponent.cs
similarity index 89%
rename from Content.Server/Atmos/Components/DeltaPressureComponent.cs
rename to Content.Shared/Atmos/Components/DeltaPressureComponent.cs
index cfe67a855b..064d67f606 100644
--- a/Content.Server/Atmos/Components/DeltaPressureComponent.cs
+++ b/Content.Shared/Atmos/Components/DeltaPressureComponent.cs
@@ -1,37 +1,37 @@
-using Content.Server.Atmos.EntitySystems;
+using Content.Shared.Atmos.EntitySystems;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Content.Shared.Guidebook;
+using Robust.Shared.GameStates;
-namespace Content.Server.Atmos.Components;
+namespace Content.Shared.Atmos.Components;
///
/// Entities that have this component will have damage done to them depending on the local pressure
/// environment that they reside in.
///
/// Atmospherics.DeltaPressure batch-processes entities with this component in a list on
-/// the grid's .
+/// the grid's GridAtmosphereComponent.
/// The entities are automatically added and removed from this list, and automatically
/// added on initialization.
///
-/// Note that the entity should have an and be a grid structure.
+/// Note that the entity should have an AirtightComponent and be a grid structure.
[RegisterComponent]
+[NetworkedComponent, AutoGenerateComponentState]
+[Access(typeof(SharedAtmosphereSystem), typeof(SharedDeltaPressureSystem))]
public sealed partial class DeltaPressureComponent : Component
{
///
- /// Whether the entity is currently in the processing list of the grid's .
+ /// Whether the entity is currently in the processing list of the grid's GridAtmosphereComponent.
///
[DataField(readOnly: true)]
[ViewVariables(VVAccess.ReadOnly)]
- [Access(typeof(DeltaPressureSystem), typeof(AtmosphereSystem))]
public bool InProcessingList;
///
/// Whether this entity is currently taking damage from pressure.
///
- [DataField(readOnly: true)]
- [ViewVariables(VVAccess.ReadOnly)]
- [Access(typeof(DeltaPressureSystem), typeof(AtmosphereSystem))]
+ [DataField, AutoNetworkedField]
public bool IsTakingDamage;
///
@@ -39,7 +39,7 @@ public sealed partial class DeltaPressureComponent : Component
/// Required for proper deletion, as we cannot reference the grid
/// for removal while the entity is being deleted.
///
- /// Note that while already stores the grid,
+ /// Note that while AirtightComponent already stores the grid,
/// we cannot trust it to be available on init or when the entity is being deleted. Tragic.
/// Double note: this is set during ComponentInit and thus does not need to be a datafield
/// or else it will spam serialization.
diff --git a/Content.Shared/Atmos/EntitySystems/SharedDeltaPressureSystem.cs b/Content.Shared/Atmos/EntitySystems/SharedDeltaPressureSystem.cs
new file mode 100644
index 0000000000..4ea9880707
--- /dev/null
+++ b/Content.Shared/Atmos/EntitySystems/SharedDeltaPressureSystem.cs
@@ -0,0 +1,20 @@
+using Content.Shared.Atmos.Components;
+using Content.Shared.Examine;
+
+namespace Content.Shared.Atmos.EntitySystems;
+
+public abstract partial class SharedDeltaPressureSystem : EntitySystem
+{
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnExaminedEvent);
+ }
+
+ private void OnExaminedEvent(Entity ent, ref ExaminedEvent args)
+ {
+ if (ent.Comp.IsTakingDamage)
+ args.PushMarkup(Loc.GetString("window-taking-damage"));
+ }
+}
--
2.51.2