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>
This commit is contained in:
ArtisticRoomba
2025-10-27 04:00:37 -07:00
committed by GitHub
parent 7c0ba70b74
commit 91292522b5
7 changed files with 57 additions and 24 deletions

View File

@@ -0,0 +1,5 @@
using Content.Shared.Atmos.EntitySystems;
namespace Content.Client.Atmos.EntitySystems;
public sealed class DeltaPressureSystem : SharedDeltaPressureSystem;

View 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;

View 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
{

View 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>

View 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)

View 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>

View File

@@ -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"));
}
}