]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
ContainerComp fix (#31434)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 25 Aug 2024 15:22:01 +0000 (01:22 +1000)
committerGitHub <noreply@github.com>
Sun, 25 Aug 2024 15:22:01 +0000 (01:22 +1000)
Forgot to push these ones on the branch.

Content.Shared/Containers/ContainerCompSystem.cs

index 1e1983a331b9f5805a0076bfbc10084f8c4ee3e0..75908efea3aca9c192cfe36795d7b97d023a32de 100644 (file)
@@ -1,5 +1,6 @@
 using Robust.Shared.Containers;
 using Robust.Shared.Prototypes;
+using Robust.Shared.Timing;
 
 namespace Content.Shared.Containers;
 
@@ -8,6 +9,7 @@ namespace Content.Shared.Containers;
 /// </summary>
 public sealed class ContainerCompSystem : EntitySystem
 {
+    [Dependency] private readonly IGameTiming _timing = default!;
     [Dependency] private readonly IPrototypeManager _proto = default!;
 
     public override void Initialize()
@@ -19,21 +21,18 @@ public sealed class ContainerCompSystem : EntitySystem
 
     private void OnConRemove(Entity<ContainerCompComponent> ent, ref EntRemovedFromContainerMessage args)
     {
-        if (args.Container.ID != ent.Comp.Container)
+        if (args.Container.ID != ent.Comp.Container || _timing.ApplyingState)
             return;
 
-        if (_proto.TryIndex(ent.Comp.Container, out var entProto))
+        if (_proto.TryIndex(ent.Comp.Proto, out var entProto))
         {
-            foreach (var entry in entProto.Components.Values)
-            {
-                RemComp(args.Entity, entry.Component);
-            }
+            EntityManager.RemoveComponents(args.Entity, entProto.Components);
         }
     }
 
     private void OnConInsert(Entity<ContainerCompComponent> ent, ref EntInsertedIntoContainerMessage args)
     {
-        if (args.Container.ID != ent.Comp.Container)
+        if (args.Container.ID != ent.Comp.Container || _timing.ApplyingState)
             return;
 
         if (_proto.TryIndex(ent.Comp.Proto, out var entProto))