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 <kevinz5000@gmail.com>
This commit is contained in:
@@ -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<ServerStorageComponent>(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))
|
||||
|
||||
Reference in New Issue
Block a user