]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Reduce unnecessary `ComponentInit` work for airtight entities (#42390)
authorTriviaSolari <154280615+TriviaSolari@users.noreply.github.com>
Thu, 15 Jan 2026 02:31:05 +0000 (21:31 -0500)
committerGitHub <noreply@github.com>
Thu, 15 Jan 2026 02:31:05 +0000 (02:31 +0000)
Refactor AirtightSystem to skip rotation checks for omnidirectional blocks on init

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
Content.Server/Atmos/Components/AirtightComponent.cs
Content.Server/Atmos/EntitySystems/AirtightSystem.cs

index 29c1f18af3a9040909898e08f1e1f57fbca5a9b0..731153be418d8cf8727e9a35fb8aeaad40b7ecee 100644 (file)
@@ -44,20 +44,6 @@ namespace Content.Server.Atmos.Components
         [DataField("rotateAirBlocked")]
         public bool RotateAirBlocked { get; set; } = true;
 
-        /// <summary>
-        /// Whether to fix the <see cref="CurrentAirBlockedDirection"/> on initialization
-        /// to the entity's current rotation.
-        /// </summary>
-        /// <remarks>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.</remarks>
-        /// <example>If your entity only blocks air in one direction,
-        /// and that can depend on rotation, this needs to be set to true.</example>
-        [DataField]
-        public bool FixAirBlockedDirectionInitialize = true;
-
         /// <summary>
         /// If true, then the tile that this entity is on will have no air at all if all directions are blocked.
         /// </summary>
index 78f61c80a477a869777df9bf6df7248758b58007..61cd8b280c6f19c5ea0af19f77590a68a0c002e5 100644 (file)
@@ -25,16 +25,17 @@ namespace Content.Server.Atmos.EntitySystems
 
         private void OnAirtightInit(Entity<AirtightComponent> 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);