]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix DoDrop to DropNextTo in container cases (#30911)
authorToken <esil.bektay@yandex.com>
Mon, 12 Aug 2024 14:18:26 +0000 (19:18 +0500)
committerGitHub <noreply@github.com>
Mon, 12 Aug 2024 14:18:26 +0000 (10:18 -0400)
* Fix DoDrop to DropNextTo in container cases
DoDrop is too heavy to calculation. In any other case we should use alternatives, for example DropNextTo helper method

* codestyle change

Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs

index 0579e997253430e0b08c5ffdb9fe7f2bfc2b2254..bdc17be91ac9a7e52648acde83a688a987842066 100644 (file)
@@ -126,13 +126,21 @@ public abstract partial class SharedHandsSystem
         var userXform = Transform(uid);
         var isInContainer = ContainerSystem.IsEntityOrParentInContainer(uid, xform: userXform);
 
+        // if the user is in a container, drop the item inside the container
+        if (isInContainer) {
+            TransformSystem.DropNextTo((entity, itemXform), (uid, userXform));
+            return true;
+        }
+        
+        // drop the item with heavy calculations from their hands and place it at the calculated interaction range position
+        // The DoDrop is handle if there's no drop target
         DoDrop(uid, hand, doDropInteraction: doDropInteraction, handsComp);
 
-        // drop the item inside the container if the user is in a container
-        if (targetDropLocation == null || isInContainer)
+        // if there's no drop location stop here
+        if (targetDropLocation == null)
             return true;
-
-        // otherwise, remove the item from their hands and place it at the calculated interaction range position
+        
+        // otherwise, also move dropped item and rotate it properly according to grid/map
         var (itemPos, itemRot) = TransformSystem.GetWorldPositionRotation(entity);
         var origin = new MapCoordinates(itemPos, itemXform.MapID);
         var target = TransformSystem.ToMapCoordinates(targetDropLocation.Value);