]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix magnet re-parenting (#23680)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 7 Jan 2024 12:57:54 +0000 (23:57 +1100)
committerGitHub <noreply@github.com>
Sun, 7 Jan 2024 12:57:54 +0000 (23:57 +1100)
Me when I test at default position and forgor to store localposition.

Content.Server/Salvage/SalvageSystem.Magnet.cs

index 2a5e15a3634ec42dbc9bd4d3487b85ff2aaf6e44..4311796302fac04ce824e5fabf3d0ffb44692d3e 100644 (file)
@@ -18,7 +18,7 @@ public sealed partial class SalvageSystem
 
     private EntityQuery<SalvageMobRestrictionsComponent> _salvMobQuery;
 
-    private List<(Entity<TransformComponent> Entity, EntityUid MapUid)> _detachEnts = new();
+    private List<(Entity<TransformComponent> Entity, EntityUid MapUid, Vector2 LocalPosition)> _detachEnts = new();
 
     private void InitializeMagnet()
     {
@@ -144,7 +144,7 @@ public sealed partial class SalvageSystem
                     continue;
 
                 // Can't parent directly to map as it runs grid traversal.
-                _detachEnts.Add(((mobUid, xform), xform.MapUid.Value));
+                _detachEnts.Add(((mobUid, xform), xform.MapUid.Value, _transform.GetWorldPosition(xform)));
                 _transform.DetachParentToNull(mobUid, xform);
             }
 
@@ -156,7 +156,7 @@ public sealed partial class SalvageSystem
 
             foreach (var entity in _detachEnts)
             {
-                _transform.SetParent(entity.Entity.Owner, entity.Entity.Comp, entity.MapUid);
+                _transform.SetCoordinates(entity.Entity.Owner, new EntityCoordinates(entity.MapUid, entity.LocalPosition));
             }
 
             data.Comp.ActiveEntities = null;