Optimization for looking up components.

Signed-off-by: AMZN-Olex <5432499+AMZN-Olex@users.noreply.github.com>
This commit is contained in:
AMZN-Olex
2021-10-05 11:26:31 -04:00
parent 37d9ef8762
commit 0a11e8ffc5
2 changed files with 36 additions and 15 deletions
@@ -201,16 +201,13 @@ namespace Multiplayer
{
if (const AZ::Entity* childEntity = componentApplication->FindEntity(childEntityId))
{
for (Component* component : childEntity->GetComponents())
if (auto* hierarchyChildComponent = childEntity->FindComponent<NetworkHierarchyChildComponent>())
{
if (component->GetUnderlyingComponentType() == NetworkHierarchyChildComponent::TYPEINFO_Uuid())
{
static_cast<NetworkHierarchyChildComponent*>(component)->SetTopLevelHierarchyRootEntity(nullptr);
}
else if (component->GetUnderlyingComponentType() == NetworkHierarchyRootComponent::TYPEINFO_Uuid())
{
static_cast<NetworkHierarchyRootComponent*>(component)->SetTopLevelHierarchyRootEntity(nullptr);
}
hierarchyChildComponent->SetTopLevelHierarchyRootEntity(nullptr);
}
else if (auto* hierarchyRootComponent = childEntity->FindComponent<NetworkHierarchyRootComponent>())
{
hierarchyRootComponent->SetTopLevelHierarchyRootEntity(nullptr);
}
}
}