Added unittest for an activation test

Signed-off-by: AMZN-Olex <5432499+AMZN-Olex@users.noreply.github.com>
This commit is contained in:
AMZN-Olex
2021-10-01 17:56:32 -04:00
parent 6e68da9382
commit 65b82b41d6
2 changed files with 47 additions and 12 deletions
@@ -14,7 +14,7 @@
namespace Multiplayer
{
void NetworkTransformComponent::NetworkTransformComponent::Reflect(AZ::ReflectContext* context)
void NetworkTransformComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
@@ -43,6 +43,11 @@ namespace Multiplayer
GetNetBindComponent()->AddEntityPreRenderEventHandler(m_entityPreRenderEventHandler);
GetNetBindComponent()->AddEntityCorrectionEventHandler(m_entityCorrectionEventHandler);
ParentEntityIdAddEvent(m_parentChangedEventHandler);
if (!HasController())
{
OnParentChanged(GetParentEntityId());
}
}
void NetworkTransformComponent::OnDeactivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating)
@@ -123,17 +128,20 @@ namespace Multiplayer
void NetworkTransformComponent::OnParentChanged(NetEntityId parentId)
{
const ConstNetworkEntityHandle parentEntityHandle = GetNetworkEntityManager()->GetEntity(parentId);
if (parentEntityHandle.Exists())
if (AZ::TransformInterface* transformComponent = GetEntity()->GetTransform())
{
if (const AZ::Entity* parentEntity = parentEntityHandle.GetEntity())
const ConstNetworkEntityHandle parentEntityHandle = GetNetworkEntityManager()->GetEntity(parentId);
if (parentEntityHandle.Exists())
{
GetEntity()->GetTransform()->SetParent(parentEntity->GetId());
if (const AZ::Entity* parentEntity = parentEntityHandle.GetEntity())
{
transformComponent->SetParent(parentEntity->GetId());
}
}
else
{
transformComponent->SetParent(AZ::EntityId());
}
}
else
{
GetEntity()->GetTransform()->SetParent(AZ::EntityId());
}
}