From 0d29b15ae00e91fb6c8116ccd634894dda17dc6d Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Tue, 11 Aug 2020 08:38:00 -0700 Subject: [PATCH] Fix StackComponent not getting removed from containers when empty (#1645) --- .../Components/Items/FloorTileItemComponent.cs | 3 --- .../GameObjects/Components/Stack/StackComponent.cs | 10 +--------- .../GameObjects/Components/SharedStackComponent.cs | 5 +++++ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Content.Server/GameObjects/Components/Items/FloorTileItemComponent.cs b/Content.Server/GameObjects/Components/Items/FloorTileItemComponent.cs index 0d31c6c2f1..f15948fc22 100644 --- a/Content.Server/GameObjects/Components/Items/FloorTileItemComponent.cs +++ b/Content.Server/GameObjects/Components/Items/FloorTileItemComponent.cs @@ -50,9 +50,6 @@ namespace Content.Server.GameObjects.Components.Items var desiredTile = _tileDefinitionManager[_outputTile]; mapGrid.SetTile(eventArgs.ClickLocation, new Tile(desiredTile.TileId)); EntitySystem.Get().PlayAtCoords("/Audio/Items/genhit.ogg", eventArgs.ClickLocation); - if(_stack.Count < 1){ - Owner.Delete(); - } } diff --git a/Content.Server/GameObjects/Components/Stack/StackComponent.cs b/Content.Server/GameObjects/Components/Stack/StackComponent.cs index 4fe5350c49..53020796c5 100644 --- a/Content.Server/GameObjects/Components/Stack/StackComponent.cs +++ b/Content.Server/GameObjects/Components/Stack/StackComponent.cs @@ -28,15 +28,7 @@ namespace Content.Server.GameObjects.Components.Stack public override int Count { get => base.Count; - set - { - base.Count = value; - - if (Count <= 0) - { - Owner.Delete(); - } - } + set => base.Count = value; } [ViewVariables(VVAccess.ReadWrite)] diff --git a/Content.Shared/GameObjects/Components/SharedStackComponent.cs b/Content.Shared/GameObjects/Components/SharedStackComponent.cs index 57ef706559..2bdb73cbcd 100644 --- a/Content.Shared/GameObjects/Components/SharedStackComponent.cs +++ b/Content.Shared/GameObjects/Components/SharedStackComponent.cs @@ -1,4 +1,5 @@ using System; +using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.Interfaces.Reflection; using Robust.Shared.IoC; @@ -26,6 +27,10 @@ namespace Content.Shared.GameObjects.Components _count = value; if (_count <= 0) { + if (ContainerHelpers.TryGetContainerMan(Owner, out var containerManager)) + { + containerManager.Remove(Owner); + } Owner.Delete(); }