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
This commit is contained in:
Whatstone 2026-08-20 20:42:08 +00:00 • committed by GitHub
parent 67030315c5
commit a6c2c43273
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)