--- /dev/null
+using Content.Shared.Atmos.EntitySystems;
+
+namespace Content.Client.Atmos.EntitySystems;
+
+public sealed class DeltaPressureSystem : SharedDeltaPressureSystem;
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;
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
{
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;
/// 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)
var aboveMinDeltaPressure = delta > ent.Comp.MinPressureDelta;
if (!aboveMinPressure && !aboveMinDeltaPressure)
{
- ent.Comp.IsTakingDamage = false;
+ SetIsTakingDamageState(ent, false);
return;
}
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>
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;
/// 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!;
SubscribeLocalEvent<DeltaPressureComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<DeltaPressureComponent, ComponentShutdown>(OnComponentShutdown);
- SubscribeLocalEvent<DeltaPressureComponent, ExaminedEvent>(OnExamined);
-
SubscribeLocalEvent<DeltaPressureComponent, GridUidChangedEvent>(OnGridChanged);
}
_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)
-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>
/// 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>
--- /dev/null
+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"));
+ }
+}