From 8938e1d8b25d903355a9e058bbb12904a270ae06 Mon Sep 17 00:00:00 2001 From: ShadowCommander Date: Sun, 12 May 2024 07:30:17 -0700 Subject: [PATCH] Replace AttachToGridOrMap with DropNextTo (#27950) --- .../EntitySystems/SliceableFoodSystem.cs | 22 ++++--------------- .../Body/Systems/SharedBodySystem.Body.cs | 6 +++-- .../EntitySystems/SharedHandsSystem.Drop.cs | 11 +++------- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs b/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs index ea422afdf0..f5d434090e 100644 --- a/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs @@ -110,15 +110,8 @@ namespace Content.Server.Nutrition.EntitySystems // try putting the slice into the container if the food being sliced is in a container! // this lets you do things like slice a pizza up inside of a hot food cart without making a food-everywhere mess - if (_containerSystem.TryGetContainingContainer(uid, out var container) && _containerSystem.CanInsert(sliceUid, container)) - { - _containerSystem.Insert(sliceUid, container); - } - else // puts it down "right-side up" - { - _xformSystem.AttachToGridOrMap(sliceUid); - _xformSystem.SetLocalRotation(sliceUid, 0); - } + _xformSystem.DropNextTo(sliceUid, (uid, transform)); + _xformSystem.SetLocalRotation(sliceUid, 0); return sliceUid; } @@ -143,15 +136,8 @@ namespace Content.Server.Nutrition.EntitySystems var trashUid = Spawn(foodComp.Trash, _xformSystem.GetMapCoordinates(uid)); // try putting the trash in the food's container too, to be consistent with slice spawning? - if (_containerSystem.TryGetContainingContainer(uid, out var container) && _containerSystem.CanInsert(trashUid, container)) - { - _containerSystem.Insert(trashUid, container); - } - else // puts it down "right-side up" - { - _xformSystem.AttachToGridOrMap(trashUid); - _xformSystem.SetLocalRotation(trashUid, 0); - } + _xformSystem.DropNextTo(trashUid, uid); + _xformSystem.SetLocalRotation(trashUid, 0); QueueDel(uid); } diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs index 1a35afdbe0..250f90db8f 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs @@ -322,15 +322,17 @@ public partial class SharedBodySystem launchImpulseVariance:GibletLaunchImpulseVariance, launchCone: splatCone); } } + + var bodyTransform = Transform(bodyId); if (TryComp(bodyId, out var inventory)) { foreach (var item in _inventory.GetHandOrInventoryEntities(bodyId)) { - SharedTransform.AttachToGridOrMap(item); + SharedTransform.DropNextTo(item, (bodyId, bodyTransform)); gibs.Add(item); } } - _audioSystem.PlayPredicted(gibSoundOverride, Transform(bodyId).Coordinates, null); + _audioSystem.PlayPredicted(gibSoundOverride, bodyTransform.Coordinates, null); return gibs; } } diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs index 7b169b5d0a..4d21e40a98 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs @@ -120,17 +120,12 @@ public abstract partial class SharedHandsSystem return true; var userXform = Transform(uid); - var isInContainer = ContainerSystem.IsEntityInContainer(uid); + var isInContainer = ContainerSystem.IsEntityOrParentInContainer(uid, xform: userXform); if (targetDropLocation == null || isInContainer) { - // If user is in a container, drop item into that container. Otherwise, attach to grid or map.\ - // TODO recursively check upwards for containers - - if (!isInContainer - || !ContainerSystem.TryGetContainingContainer(userXform.ParentUid, uid, out var container, skipExistCheck: true) - || !ContainerSystem.Insert((entity, itemXform), container)) - TransformSystem.AttachToGridOrMap(entity, itemXform); + // If user is in a container, drop item into that container. Otherwise, attach to grid or map. + TransformSystem.DropNextTo((entity, itemXform), (uid, userXform)); return true; } -- 2.51.2