Converted to use AZ::Events for hiearchy notifications. Added unittests.

Signed-off-by: AMZN-Olex <5432499+AMZN-Olex@users.noreply.github.com>
This commit is contained in:
AMZN-Olex
2021-09-14 11:50:51 -04:00
parent 088511577b
commit fcd5b3f184
9 changed files with 131 additions and 37 deletions
@@ -98,6 +98,16 @@ namespace Multiplayer
return {};
}
void NetworkHierarchyChildComponent::BindNetworkHierarchyChangedEventHandler(NetworkHierarchyChangedEvent::Handler& handler)
{
handler.Connect(m_networkHierarchyChangedEvent);
}
void NetworkHierarchyChildComponent::BindNetworkHierarchyLeaveEventHandler(NetworkHierarchyLeaveEvent::Handler& handler)
{
handler.Connect(m_networkHierarchyLeaveEvent);
}
void NetworkHierarchyChildComponent::SetTopLevelHierarchyRootComponent(NetworkHierarchyRootComponent* hierarchyRoot)
{
m_hierarchyRootComponent = hierarchyRoot;
@@ -109,12 +119,13 @@ namespace Multiplayer
const NetEntityId netRootId = GetNetworkEntityManager()->GetNetEntityIdById(hierarchyRoot->GetEntityId());
controller->SetHierarchyRoot(netRootId);
NetworkHierarchyNotificationBus::Event(GetEntityId(), &NetworkHierarchyNotificationBus::Events::OnNetworkHierarchyUpdated, hierarchyRoot->GetEntityId());
m_networkHierarchyChangedEvent.Signal(hierarchyRoot->GetEntityId());
}
else
{
controller->SetHierarchyRoot(InvalidNetEntityId);
NetworkHierarchyNotificationBus::Event(GetEntityId(), &NetworkHierarchyNotificationBus::Events::OnNetworkHierarchyLeave);
m_networkHierarchyLeaveEvent.Signal();
}
}
}
@@ -125,10 +136,12 @@ namespace Multiplayer
if (rootHandle.Exists())
{
m_hierarchyRootComponent = rootHandle.FindComponent<NetworkHierarchyRootComponent>();
m_networkHierarchyChangedEvent.Signal(m_hierarchyRootComponent->GetEntityId());
}
else
{
m_hierarchyRootComponent = nullptr;
m_networkHierarchyLeaveEvent.Signal();
}
}
}