]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix skeletons spawning in folded body bags (#37151)
authoryoutissoum <51883137+youtissoum@users.noreply.github.com>
Sat, 3 May 2025 19:19:32 +0000 (21:19 +0200)
committerGitHub <noreply@github.com>
Sat, 3 May 2025 19:19:32 +0000 (21:19 +0200)
* Fix skeleton spawning

* Add comments

* Fix the comments

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Shared/Foldable/FoldableSystem.cs
Content.Shared/Storage/Components/SharedEntityStorageComponent.cs
Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs

index 73916f1c154e17e53ec86b72d9c8548008c9f46e..63ef376d5f2ca125c727e0d2221985c0e3709d24 100644 (file)
@@ -30,6 +30,7 @@ public sealed class FoldableSystem : EntitySystem
         SubscribeLocalEvent<FoldableComponent, ComponentInit>(OnFoldableInit);
         SubscribeLocalEvent<FoldableComponent, ContainerGettingInsertedAttemptEvent>(OnInsertEvent);
         SubscribeLocalEvent<FoldableComponent, StorageOpenAttemptEvent>(OnFoldableOpenAttempt);
+        SubscribeLocalEvent<FoldableComponent, EntityStorageInsertedIntoAttemptEvent>(OnEntityStorageAttemptInsert);
 
         SubscribeLocalEvent<FoldableComponent, StrapAttemptEvent>(OnStrapAttempt);
     }
@@ -56,6 +57,13 @@ public sealed class FoldableSystem : EntitySystem
             args.Cancelled = true;
     }
 
+    private void OnEntityStorageAttemptInsert(Entity<FoldableComponent> entity,
+        ref EntityStorageInsertedIntoAttemptEvent args)
+    {
+        if (entity.Comp.IsFolded)
+            args.Cancelled = true;
+    }
+
     /// <summary>
     /// Returns false if the entity isn't foldable.
     /// </summary>
index 06b1c15f2e1397a92996ef30a5c842fc94b417e6..a0d4e418ccea8c79a7591350b0a0ecbf1465264b 100644 (file)
@@ -146,9 +146,18 @@ public sealed class EntityStorageComponentState : ComponentState
     }
 }
 
+/// <summary>
+/// Raised on the entity being inserted whenever checking if an entity can be inserted into an entity storage.
+/// </summary>
 [ByRefEvent]
 public record struct InsertIntoEntityStorageAttemptEvent(EntityUid ItemToInsert, bool Cancelled = false);
 
+/// <summary>
+/// Raised on the entity storage whenever checking if an entity can be inserted into it.
+/// </summary>
+[ByRefEvent]
+public record struct EntityStorageInsertedIntoAttemptEvent(EntityUid ItemToInsert, bool Cancelled = false);
+
 [ByRefEvent]
 public record struct StorageOpenAttemptEvent(EntityUid User, bool Silent, bool Cancelled = false);
 
index 75088bfeecb1d2ce6ed136de23d1edda93624601..2b73a9349fc1b9619db3b9dba03fd3b35c833e6c 100644 (file)
@@ -343,6 +343,13 @@ public abstract class SharedEntityStorageSystem : EntitySystem
         if (attemptEvent.Cancelled)
             return false;
 
+        // Allow other components on the container to prevent inserting the item: e.g. the container is folded
+        var containerAttemptEvent = new EntityStorageInsertedIntoAttemptEvent(toInsert);
+        RaiseLocalEvent(container, ref containerAttemptEvent);
+
+        if (containerAttemptEvent.Cancelled)
+            return false;
+
         // Consult the whitelist. The whitelist ignores the default assumption about how entity storage works.
         if (component.Whitelist != null)
             return _whitelistSystem.IsValid(component.Whitelist, toInsert);