From 31844fa88e47b14587a960b052b4900e72495b7b Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Sat, 8 May 2021 11:27:20 -0700 Subject: [PATCH] Fix thrown breakables (#3944) * Fix bottles and lights being parented to player * Fix item pickup animation --- .../Thresholds/Behaviors/SpawnEntitiesBehavior.cs | 6 +++--- .../GameObjects/Components/GUI/HandsComponent.cs | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Content.Server/GameObjects/Components/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs b/Content.Server/GameObjects/Components/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs index d69a8071de..5c708e1fc1 100644 --- a/Content.Server/GameObjects/Components/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs +++ b/Content.Server/GameObjects/Components/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable using System; using System.Collections.Generic; using Content.Server.GameObjects.Components.Stack; @@ -31,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Destructible.Thresholds.Behavior if (EntityPrototypeHelpers.HasComponent(entityId)) { - var spawned = owner.EntityManager.SpawnEntity(entityId, owner.Transform.Coordinates); + var spawned = owner.EntityManager.SpawnEntity(entityId, owner.Transform.MapPosition); var stack = spawned.GetComponent(); stack.Count = count; spawned.RandomOffset(0.5f); @@ -40,7 +40,7 @@ namespace Content.Server.GameObjects.Components.Destructible.Thresholds.Behavior { for (var i = 0; i < count; i++) { - var spawned = owner.EntityManager.SpawnEntity(entityId, owner.Transform.Coordinates); + var spawned = owner.EntityManager.SpawnEntity(entityId, owner.Transform.MapPosition); spawned.RandomOffset(0.5f); } } diff --git a/Content.Server/GameObjects/Components/GUI/HandsComponent.cs b/Content.Server/GameObjects/Components/GUI/HandsComponent.cs index f9e864e9cb..624dd60dbf 100644 --- a/Content.Server/GameObjects/Components/GUI/HandsComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/HandsComponent.cs @@ -172,15 +172,16 @@ namespace Content.Server.GameObjects.Components.GUI Dirty(); - var position = item.Owner.Transform.Coordinates; + var oldParent = item.Owner.Transform.Parent; + var oldPosition = item.Owner.Transform.Coordinates; var contained = item.Owner.IsInContainer(); var success = hand.Container.Insert(item.Owner); if (success) { //If the entity isn't in a container, and it isn't located exactly at our position (i.e. in our own storage), then we can safely play the animation - if (position != Owner.Transform.Coordinates && !contained) + if (oldParent != Owner.Transform && !contained) { - SendNetworkMessage(new AnimatePickupEntityMessage(item.Owner.Uid, position)); + SendNetworkMessage(new AnimatePickupEntityMessage(item.Owner.Uid, oldPosition)); } item.Owner.Transform.LocalPosition = Vector2.Zero; OnItemChanged?.Invoke();