]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Replace AttachToGridOrMap with DropNextTo (#27950)
authorShadowCommander <shadowjjt@gmail.com>
Sun, 12 May 2024 14:30:17 +0000 (07:30 -0700)
committerGitHub <noreply@github.com>
Sun, 12 May 2024 14:30:17 +0000 (10:30 -0400)
Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs
Content.Shared/Body/Systems/SharedBodySystem.Body.cs
Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs

index ea422afdf019fd6a94efe812e8eef249590d08aa..f5d434090e74f1db967b52a7b506c63feafeb2af 100644 (file)
@@ -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);
         }
index 1a35afdbe00385b944ec00bd55f12c4b8affa0ec..250f90db8f37e886dd8765e408b237a58dce0884 100644 (file)
@@ -322,15 +322,17 @@ public partial class SharedBodySystem
                     launchImpulseVariance:GibletLaunchImpulseVariance, launchCone: splatCone);
             }
         }
+
+        var bodyTransform = Transform(bodyId);
         if (TryComp<InventoryComponent>(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;
     }
 }
index 7b169b5d0a6f299e0ae45278fa6d23c8a4ea764d..4d21e40a98723f1ccafaf02199b0690a795178ac 100644 (file)
@@ -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;
         }