From d6377862c1f8fa7539320a2229fc0486679d5564 Mon Sep 17 00:00:00 2001 From: TriviaSolari <154280615+TriviaSolari@users.noreply.github.com> Date: Wed, 14 Jan 2026 21:31:05 -0500 Subject: [PATCH] Reduce unnecessary `ComponentInit` work for airtight entities (#42390) Refactor AirtightSystem to skip rotation checks for omnidirectional blocks on init Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com> --- .../Atmos/Components/AirtightComponent.cs | 14 -------------- .../Atmos/EntitySystems/AirtightSystem.cs | 11 ++++++----- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/Content.Server/Atmos/Components/AirtightComponent.cs b/Content.Server/Atmos/Components/AirtightComponent.cs index 29c1f18af3..731153be41 100644 --- a/Content.Server/Atmos/Components/AirtightComponent.cs +++ b/Content.Server/Atmos/Components/AirtightComponent.cs @@ -44,20 +44,6 @@ namespace Content.Server.Atmos.Components [DataField("rotateAirBlocked")] public bool RotateAirBlocked { get; set; } = true; - /// - /// Whether to fix the on initialization - /// to the entity's current rotation. - /// - /// This is an optimization routine for initializing airtight components. - /// If this entity doesn't have unique airtight directions - /// (ex. not all directions are blocked but some are), we can skip - /// a lot of event/transform business during initialization. - /// This field marks whether this is skipped or not. - /// If your entity only blocks air in one direction, - /// and that can depend on rotation, this needs to be set to true. - [DataField] - public bool FixAirBlockedDirectionInitialize = true; - /// /// If true, then the tile that this entity is on will have no air at all if all directions are blocked. /// diff --git a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs index 78f61c80a4..61cd8b280c 100644 --- a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs @@ -25,16 +25,17 @@ namespace Content.Server.Atmos.EntitySystems private void OnAirtightInit(Entity airtight, ref ComponentInit args) { - // If this entity has unique airtight directions that are affected by rotation, - // we need to fix up the current airtight directions based on its rotation. - // Otherwise, we can skip all of that logic (stuff adds up when you're initing - // a morbillion walls). - if (!airtight.Comp.FixAirBlockedDirectionInitialize) + // If this entity blocks air in all directions (e.g. full tile walls, doors, and windows) + // we can skip some expensive logic. + if (airtight.Comp.InitialAirBlockedDirection == (int)AtmosDirection.All) { + airtight.Comp.CurrentAirBlockedDirection = airtight.Comp.InitialAirBlockedDirection; UpdatePosition(airtight); return; } + // Otherwise we need to determine its current blocked air directions based on rotation + // and check if it's still airtight. var xform = Transform(airtight); airtight.Comp.CurrentAirBlockedDirection = (int) Rotate((AtmosDirection) airtight.Comp.InitialAirBlockedDirection, xform.LocalRotation); -- 2.52.0