]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Minor entitystorage air fixes (#14842)
authorKara <lunarautomaton6@gmail.com>
Sat, 25 Mar 2023 04:30:19 +0000 (21:30 -0700)
committerGitHub <noreply@github.com>
Sat, 25 Mar 2023 04:30:19 +0000 (15:30 +1100)
Content.Server/Storage/EntitySystems/EntityStorageSystem.cs

index 46459105bf98934f5a322f3f5571ea5d1979192c..509dec8a3d1026cd59323e26789c5abf98702dc9 100644 (file)
@@ -20,6 +20,7 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
     {
         base.Initialize();
 
+        SubscribeLocalEvent<EntityStorageComponent, MapInitEvent>(OnMapInit);
         SubscribeLocalEvent<EntityStorageComponent, WeldableAttemptEvent>(OnWeldableAttempt);
         SubscribeLocalEvent<EntityStorageComponent, WeldableChangedEvent>(OnWelded);
 
@@ -30,19 +31,22 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
         SubscribeLocalEvent<InsideEntityStorageComponent, EntGotRemovedFromContainerMessage>(OnRemoved);
     }
 
+    private void OnMapInit(EntityUid uid, EntityStorageComponent component, MapInitEvent args)
+    {
+        if (!component.Open && component.Air.TotalMoles == 0)
+        {
+            // If we're closed on spawn and have no air already saved, we need to pull some air into our environment from where we spawned,
+            // so that we have -something-. For example, if you bought an animal crate or something.
+            TakeGas(uid, component);
+        }
+    }
+
     protected override void OnInit(EntityUid uid, SharedEntityStorageComponent component, ComponentInit args)
     {
         base.OnInit(uid, component, args);
 
         if (TryComp<ConstructionComponent>(uid, out var construction))
             _construction.AddContainer(uid, ContainerName, construction);
-
-        if (!component.Open)
-        {
-            // If we're closed on spawn, we need to pull some air into our environment from where we spawned,
-            // so that we have -something-. For example, if you bought an animal crate or something.
-            TakeGas(uid, (EntityStorageComponent) component);
-        }
     }
 
     private void OnWeldableAttempt(EntityUid uid, EntityStorageComponent component, WeldableAttemptEvent args)