From 0501ae4b89842edcb090738485ae399a3f8c26ca Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Fri, 6 Aug 2021 18:11:39 +0200 Subject: [PATCH] Fix pickup animation incorrect coordinate usage. Animation finalPosition was world position, while initialPosition was local position. --- Content.Client/Animations/ReusableAnimations.cs | 2 +- Content.Client/Storage/ClientStorageComponent.cs | 2 +- Content.Server/Hands/Components/HandsComponent.cs | 6 +++--- Content.Shared/Hands/Components/SharedHandsComponent.cs | 4 ++-- Resources/Changelog/Parts/pickup.yml | 4 ++++ 5 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 Resources/Changelog/Parts/pickup.yml diff --git a/Content.Client/Animations/ReusableAnimations.cs b/Content.Client/Animations/ReusableAnimations.cs index 2cb7c67c43..eef860ce54 100644 --- a/Content.Client/Animations/ReusableAnimations.cs +++ b/Content.Client/Animations/ReusableAnimations.cs @@ -11,7 +11,7 @@ namespace Content.Client.Animations { public static class ReusableAnimations { - public static void AnimateEntityPickup(IEntity entity, EntityCoordinates initialPosition, Vector2 finalPosition) + public static void AnimateEntityPickup(IEntity entity, MapCoordinates initialPosition, Vector2 finalPosition) { var animatableClone = entity.EntityManager.SpawnEntity("clientsideclone", initialPosition); animatableClone.Name = entity.Name; diff --git a/Content.Client/Storage/ClientStorageComponent.cs b/Content.Client/Storage/ClientStorageComponent.cs index c194b6d296..17039981ca 100644 --- a/Content.Client/Storage/ClientStorageComponent.cs +++ b/Content.Client/Storage/ClientStorageComponent.cs @@ -116,7 +116,7 @@ namespace Content.Client.Storage for (var i = 0; msg.StoredEntities.Count > i; i++) { var entityId = msg.StoredEntities[i]; - var initialPosition = msg.EntityPositions[i]; + var initialPosition = msg.EntityPositions[i].ToMap(Owner.EntityManager); if (Owner.EntityManager.TryGetEntity(entityId, out var entity)) { diff --git a/Content.Server/Hands/Components/HandsComponent.cs b/Content.Server/Hands/Components/HandsComponent.cs index f8b84c9992..8f2579eaf6 100644 --- a/Content.Server/Hands/Components/HandsComponent.cs +++ b/Content.Server/Hands/Components/HandsComponent.cs @@ -86,15 +86,15 @@ namespace Content.Server.Hands.Components protected override void HandlePickupAnimation(IEntity entity) { - var pickupDirection = Owner.Transform.WorldPosition; + var pickupDirection = Owner.Transform.MapPosition.Position; var outermostEntity = entity; while (outermostEntity.TryGetContainer(out var container)) //TODO: Use WorldPosition instead of this loop outermostEntity = container.Owner; - var initialPosition = outermostEntity.Transform.Coordinates; + var initialPosition = outermostEntity.Transform.MapPosition; - if (pickupDirection == initialPosition.ToMapPos(Owner.EntityManager)) + if (pickupDirection == initialPosition.Position) return; Owner.EntityManager.EntityNetManager!.SendSystemNetworkMessage( diff --git a/Content.Shared/Hands/Components/SharedHandsComponent.cs b/Content.Shared/Hands/Components/SharedHandsComponent.cs index 9e1978b06f..3625502e0f 100644 --- a/Content.Shared/Hands/Components/SharedHandsComponent.cs +++ b/Content.Shared/Hands/Components/SharedHandsComponent.cs @@ -923,10 +923,10 @@ namespace Content.Shared.Hands.Components public class PickupAnimationMessage : EntityEventArgs { public EntityUid EntityUid { get; } - public EntityCoordinates InitialPosition { get; } + public MapCoordinates InitialPosition { get; } public Vector2 PickupDirection { get; } - public PickupAnimationMessage(EntityUid entityUid, Vector2 pickupDirection, EntityCoordinates initialPosition) + public PickupAnimationMessage(EntityUid entityUid, Vector2 pickupDirection, MapCoordinates initialPosition) { EntityUid = entityUid; PickupDirection = pickupDirection; diff --git a/Resources/Changelog/Parts/pickup.yml b/Resources/Changelog/Parts/pickup.yml new file mode 100644 index 0000000000..ea08f40154 --- /dev/null +++ b/Resources/Changelog/Parts/pickup.yml @@ -0,0 +1,4 @@ +author: Your_Name_Here +changes: + - type: Fix # One of the following: Add, Remove, Tweak, Fix + message: Fixes pickup animation not showing under certain conditions.