From ae4c7ad0bc1a684ec02445adb4697c6c3ee003f2 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 26 Aug 2024 01:22:01 +1000 Subject: [PATCH] ContainerComp fix (#31434) Forgot to push these ones on the branch. --- Content.Shared/Containers/ContainerCompSystem.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Content.Shared/Containers/ContainerCompSystem.cs b/Content.Shared/Containers/ContainerCompSystem.cs index 1e1983a331..75908efea3 100644 --- a/Content.Shared/Containers/ContainerCompSystem.cs +++ b/Content.Shared/Containers/ContainerCompSystem.cs @@ -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; /// 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 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 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))