From a6c2c432736b5e3591a6800b61925e4ba2cec36e Mon Sep 17 00:00:00 2001 From: Whatstone <166147148+whatston3@users.noreply.github.com> Date: Thu, 20 Aug 2026 20:42:08 +0000 Subject: [PATCH] Bugfix: SharedEntitySystem.Remove parents you to the grid or the map. (#45503) * SharedEntityStorageSystem: fix parent on remove * Remove unused MapSystem reference * .Value it is then --- .../EntitySystems/SharedEntityStorageSystem.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs index bf76bf2c40..0ad1a866e6 100644 --- a/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs @@ -6,9 +6,7 @@ using Content.Shared.Explosion; using Content.Shared.Foldable; using Content.Shared.Hands.Components; using Content.Shared.Interaction; -using Content.Shared.Item; using Content.Shared.Lock; -using Content.Shared.Mobs.Components; using Content.Shared.Movement.Events; using Content.Shared.Popups; using Content.Shared.Storage.Components; @@ -327,13 +325,16 @@ public abstract partial class SharedEntityStorageSystem : EntitySystem if (!Resolve(container, ref component)) return false; - var toRemoveTransform = Transform(toRemove); - if (toRemoveTransform.MapUid is not { } toRemoveMap) + // Get our new parent: either the grid the entity is on, or the + var newParent = xform.GridUid ?? xform.MapUid; + if (!TryComp(newParent, out TransformComponent? parentXform)) return false; + // Reparent the removed entity to our grid, or the map! var (pos, rot) = TransformSystem.GetWorldPositionRotation(xform); pos += rot.RotateVec(component.EnteringOffset); - if (!_container.Remove(toRemove, component.Contents, destination: new(toRemoveMap, pos))) + pos = Vector2.Transform(pos, TransformSystem.GetInvWorldMatrix(parentXform)); + if (!_container.Remove(toRemove, component.Contents, destination: new(newParent.Value, pos))) return false; if (_container.IsEntityInContainer(container)