diff --git a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs
index 37542f6469..49a82f609d 100644
--- a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs
+++ b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs
@@ -4,6 +4,7 @@ using System.Linq;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects;
using Robust.Server.GameObjects.Components.Container;
+using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
@@ -14,6 +15,7 @@ using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
using static Content.Shared.GameObjects.SharedInventoryComponent.ClientInventoryMessage;
+using IComponent = Robust.Shared.Interfaces.GameObjects.IComponent;
namespace Content.Server.GameObjects
{
@@ -222,6 +224,24 @@ namespace Content.Server.GameObjects
return SlotContainers.ContainsKey(slot);
}
+ ///
+ /// The underlying Container System just notified us that an entity was removed from it.
+ /// We need to make sure we process that removed entity as being unequpped from the slot.
+ ///
+ private void ForceUnequip(IContainer container, IEntity entity)
+ {
+ // make sure this is one of our containers.
+ // Technically the correct way would be to enumerate the possible slot names
+ // comparing with this container, but I might as well put the dictionary to good use.
+ if (!(container is ContainerSlot slot) || !SlotContainers.ContainsValue(slot))
+ return;
+
+ if (entity.TryGetComponent(out ItemComponent itemComp))
+ itemComp.RemovedFromSlot();
+
+ Dirty();
+ }
+
///
/// Message that tells us to equip or unequip items from the inventory slots
///
@@ -291,6 +311,11 @@ namespace Content.Server.GameObjects
if (item != null && item.Owner.TryGetComponent(out ServerStorageComponent storage))
storage.OpenStorageUI(Owner);
break;
+
+ case ContainerContentsModifiedMessage msg:
+ if (msg.Removed)
+ ForceUnequip(msg.Container, msg.Entity);
+ break;
}
}
diff --git a/RobustToolbox b/RobustToolbox
index 566ed9cbdc..c8ff91bf72 160000
--- a/RobustToolbox
+++ b/RobustToolbox
@@ -1 +1 @@
-Subproject commit 566ed9cbdc63465b69b1f65bb09c8d42cf2b5ff0
+Subproject commit c8ff91bf72969053ac06711e3b0cd28d86fe2ba4