From e8960f77b2e0d447972be47267f4955109751a68 Mon Sep 17 00:00:00 2001 From: chromiumboy <50505512+chromiumboy@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:32:51 -0500 Subject: [PATCH] Drop stored entities from containers used in crafting recipes (#18564) Resolves issue #10852. If a storage container is a reagent for crafting, items stored inside of it are dropped. --------- Co-authored-by: Kevin Zheng --- .../Construction/ConstructionSystem.Initial.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index 564e1cd24e..2284ade6bd 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; using Content.Server.Construction.Components; using Content.Server.Storage.Components; +using Content.Server.Storage.EntitySystems; using Content.Shared.ActionBlocker; using Content.Shared.Construction; using Content.Shared.Construction.Prototypes; @@ -14,6 +15,7 @@ using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; using Content.Shared.Inventory; +using Content.Shared.Storage; using Robust.Shared.Containers; using Robust.Shared.Players; using Robust.Shared.Timing; @@ -28,6 +30,7 @@ namespace Content.Server.Construction [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly EntityLookupSystem _lookupSystem = default!; + [Dependency] private readonly StorageSystem _storageSystem = default!; // --- WARNING! LEGACY CODE AHEAD! --- // This entire file contains the legacy code for initial construction. @@ -203,6 +206,15 @@ namespace Content.Server.Construction if (used.Contains(entity)) continue; + // Dump out any stored entities in used entity + if (TryComp(entity, out var storage) && storage.StoredEntities != null) + { + foreach (var storedEntity in storage.StoredEntities.ToList()) + { + _storageSystem.RemoveAndDrop(entity, storedEntity, storage); + } + } + if (string.IsNullOrEmpty(arbitraryStep.Store)) { if (!container.Insert(entity))