]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
DeltaPressure Predicted Examine (#41135)
authorArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
Mon, 27 Oct 2025 11:00:37 +0000 (04:00 -0700)
committerGitHub <noreply@github.com>
Mon, 27 Oct 2025 11:00:37 +0000 (11:00 +0000)
* 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>
Content.Client/Atmos/EntitySystems/DeltaPressureSystem.cs [new file with mode: 0644]
Content.IntegrationTests/Tests/Atmos/DeltaPressureTest.cs
Content.Server/Atmos/Components/GridAtmosphereComponent.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.DeltaPressure.cs
Content.Server/Atmos/EntitySystems/DeltaPressureSystem.cs
Content.Shared/Atmos/Components/DeltaPressureComponent.cs [moved from Content.Server/Atmos/Components/DeltaPressureComponent.cs with 89% similarity]
Content.Shared/Atmos/EntitySystems/SharedDeltaPressureSystem.cs [new file with mode: 0644]

diff --git a/Content.Client/Atmos/EntitySystems/DeltaPressureSystem.cs b/Content.Client/Atmos/EntitySystems/DeltaPressureSystem.cs
new file mode 100644 (file)
index 0000000..3d9893a
--- /dev/null
@@ -0,0 +1,5 @@
+using Content.Shared.Atmos.EntitySystems;
+
+namespace Content.Client.Atmos.EntitySystems;
+
+public sealed class DeltaPressureSystem : SharedDeltaPressureSystem;
index 839e0ea8972723771858b14d5d4f730f4cfc8df1..c3b3877c9862ac52d19bedd5d1a3df3f3bac740e 100644 (file)
@@ -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;
index 2d36d2bd148ca967316f9e4869cc428287fec528..2a0d87515cb45bd441580959ec6685ac0ff31d64 100644 (file)
@@ -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
 {
index efddcaf1a7bb8f7445f97bef7bca5c2a62e16295..255e58dcbf5f724edbeba6af743313d7dbdb0d62 100644 (file)
@@ -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.</param>
     /// <param name="pressure">The current absolute pressure being experienced by the entity.</param>
     /// <param name="delta">The current delta pressure being experienced by the entity.</param>
-    private static void EnqueueDeltaPressureDamage(Entity<DeltaPressureComponent> ent,
+    private void EnqueueDeltaPressureDamage(Entity<DeltaPressureComponent> 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);
+    }
+
+    /// <summary>
+    /// Helper function to prevent spamming clients with dirty events when the damage state hasn't changed.
+    /// </summary>
+    /// <param name="ent">The entity to check.</param>
+    /// <param name="toSet">The value to set.</param>
+    private void SetIsTakingDamageState(Entity<DeltaPressureComponent> ent, bool toSet)
+    {
+        if (ent.Comp.IsTakingDamage == toSet)
+            return;
+        ent.Comp.IsTakingDamage = toSet;
+        Dirty(ent);
     }
 
     /// <summary>
index dd7091c270ff88f44dc9a1eb221c467db967e92d..669735b90da28010fc714c41816648ef127abc18 100644 (file)
@@ -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.</para>
 /// </summary>
-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<DeltaPressureComponent, ComponentInit>(OnComponentInit);
         SubscribeLocalEvent<DeltaPressureComponent, ComponentShutdown>(OnComponentShutdown);
-        SubscribeLocalEvent<DeltaPressureComponent, ExaminedEvent>(OnExamined);
-
         SubscribeLocalEvent<DeltaPressureComponent, GridUidChangedEvent>(OnGridChanged);
     }
 
@@ -48,12 +46,6 @@ public sealed class DeltaPressureSystem : EntitySystem
         _atmosphereSystem.TryRemoveDeltaPressureEntity(ent.Comp.GridUid.Value, ent);
     }
 
-    private void OnExamined(Entity<DeltaPressureComponent> ent, ref ExaminedEvent args)
-    {
-        if (ent.Comp.IsTakingDamage)
-            args.PushMarkup(Loc.GetString("window-taking-damage"));
-    }
-
     private void OnGridChanged(Entity<DeltaPressureComponent> ent, ref GridUidChangedEvent args)
     {
         if (args.OldGrid != null)
similarity index 89%
rename from Content.Server/Atmos/Components/DeltaPressureComponent.cs
rename to Content.Shared/Atmos/Components/DeltaPressureComponent.cs
index cfe67a855b4bfd977fde333a88ddba81795b5766..064d67f606b679ac82e581938d85e4c7d5eb088f 100644 (file)
@@ -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;
 
 /// <summary>
 /// 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 <see cref="GridAtmosphereComponent"/>.
+/// the grid's GridAtmosphereComponent.
 /// The entities are automatically added and removed from this list, and automatically
 /// added on initialization.
 /// </summary>
-/// <remarks> Note that the entity should have an <see cref="AirtightComponent"/> and be a grid structure.</remarks>
+/// <remarks> Note that the entity should have an AirtightComponent and be a grid structure.</remarks>
 [RegisterComponent]
+[NetworkedComponent, AutoGenerateComponentState]
+[Access(typeof(SharedAtmosphereSystem), typeof(SharedDeltaPressureSystem))]
 public sealed partial class DeltaPressureComponent : Component
 {
     /// <summary>
-    /// Whether the entity is currently in the processing list of the grid's <see cref="GridAtmosphereComponent"/>.
+    /// Whether the entity is currently in the processing list of the grid's GridAtmosphereComponent.
     /// </summary>
     [DataField(readOnly: true)]
     [ViewVariables(VVAccess.ReadOnly)]
-    [Access(typeof(DeltaPressureSystem), typeof(AtmosphereSystem))]
     public bool InProcessingList;
 
     /// <summary>
     /// Whether this entity is currently taking damage from pressure.
     /// </summary>
-    [DataField(readOnly: true)]
-    [ViewVariables(VVAccess.ReadOnly)]
-    [Access(typeof(DeltaPressureSystem), typeof(AtmosphereSystem))]
+    [DataField, AutoNetworkedField]
     public bool IsTakingDamage;
 
     /// <summary>
@@ -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.
     /// </summary>
-    /// <remarks>Note that while <see cref="AirtightComponent"/> already stores the grid,
+    /// <remarks>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.</remarks>
diff --git a/Content.Shared/Atmos/EntitySystems/SharedDeltaPressureSystem.cs b/Content.Shared/Atmos/EntitySystems/SharedDeltaPressureSystem.cs
new file mode 100644 (file)
index 0000000..4ea9880
--- /dev/null
@@ -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<DeltaPressureComponent, ExaminedEvent>(OnExaminedEvent);
+    }
+
+    private void OnExaminedEvent(Entity<DeltaPressureComponent> ent, ref ExaminedEvent args)
+    {
+        if (ent.Comp.IsTakingDamage)
+            args.PushMarkup(Loc.GetString("window-taking-damage"));
+    }
+}