From ab537a0f56ccf38a24cd24de30ad62fbcec3a87e Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 25 Oct 2020 22:09:56 +1100 Subject: [PATCH] Content-side grid-parenting (#2371) Shouldn't be setting WorldPosition with these IMO. Co-authored-by: Metal Gear Sloth --- .../Items/Storage/EntityStorageComponent.cs | 31 +------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs index f849c6469f..da88408b93 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs @@ -226,7 +226,6 @@ namespace Content.Server.GameObjects.Components.Items.Storage private bool AddToContents(IEntity entity) { - var physics = Owner.GetComponent(); if (entity.TryGetComponent(out IPhysicsComponent entityPhysicsComponent)) { if(MaxSize < entityPhysicsComponent.WorldAABB.Size.X @@ -234,39 +233,11 @@ namespace Content.Server.GameObjects.Components.Items.Storage { return false; } - - if (physics.WorldAABB.Left > entityPhysicsComponent.WorldAABB.Left) - { - entity.Transform.WorldPosition += new Vector2(physics.WorldAABB.Left - entityPhysicsComponent.WorldAABB.Left, 0); - } - else if (physics.WorldAABB.Right < entityPhysicsComponent.WorldAABB.Right) - { - entity.Transform.WorldPosition += new Vector2(physics.WorldAABB.Right - entityPhysicsComponent.WorldAABB.Right, 0); - } - if (physics.WorldAABB.Bottom > entityPhysicsComponent.WorldAABB.Bottom) - { - entity.Transform.WorldPosition += new Vector2(0, physics.WorldAABB.Bottom - entityPhysicsComponent.WorldAABB.Bottom); - } - else if (physics.WorldAABB.Top < entityPhysicsComponent.WorldAABB.Top) - { - entity.Transform.WorldPosition += new Vector2(0, physics.WorldAABB.Top - entityPhysicsComponent.WorldAABB.Top); - } } if (Contents.CanInsert(entity)) { - // Because Insert sets the local position to (0,0), and we want to keep the contents spread out, - // we re-apply the world position after inserting. - Vector2 worldPos; - if (entity.HasComponent()) - { - worldPos = Owner.Transform.WorldPosition; - } - else - { - worldPos = entity.Transform.WorldPosition; - } Contents.Insert(entity); - entity.Transform.WorldPosition = worldPos; + entity.Transform.LocalPosition = Vector2.Zero; if (entityPhysicsComponent != null) { entityPhysicsComponent.CanCollide = false;