Fixed crash in ConstEntityHandle. Added hierarchical correction data serialization

Signed-off-by: pereslav <pereslav@amazon.com>
This commit is contained in:
pereslav
2021-10-08 21:19:22 +01:00
parent cb53389004
commit 0c2c042fde
6 changed files with 51 additions and 8 deletions
@@ -452,4 +452,29 @@ namespace Multiplayer
}
}
bool NetworkHierarchyRootComponent::SerializeEntityCorrection(AzNetworking::ISerializer& serializer)
{
bool result = true;
INetworkEntityManager* networkEntityManager = AZ::Interface<INetworkEntityManager>::Get();
AZ_Assert(networkEntityManager, "NetworkEntityManager must be created.");
for (AZ::Entity* child : m_hierarchicalEntities)
{
if (child == GetEntity())
{
// Skip the root entity
continue;
}
NetEntityId childNetEntitydId = networkEntityManager->GetNetEntityIdById(child->GetId());
ConstNetworkEntityHandle childEntityHandle = networkEntityManager->GetEntity(childNetEntitydId);
NetBindComponent* netBindComponent = childEntityHandle.GetNetBindComponent();
AZ_Assert(netBindComponent, "No NetBindComponent, this should be impossible");
result = result && netBindComponent->SerializeEntityCorrection(serializer);
}
return result;
}
}