diff --git a/Gems/Multiplayer/Code/Include/Multiplayer/Components/NetworkHierarchyRootComponent.h b/Gems/Multiplayer/Code/Include/Multiplayer/Components/NetworkHierarchyRootComponent.h index cafd63b223..f0ad3baf94 100644 --- a/Gems/Multiplayer/Code/Include/Multiplayer/Components/NetworkHierarchyRootComponent.h +++ b/Gems/Multiplayer/Code/Include/Multiplayer/Components/NetworkHierarchyRootComponent.h @@ -108,7 +108,7 @@ namespace Multiplayer //! NetworkHierarchyRootComponentController //! This is the network controller for NetworkHierarchyRootComponent. //! Class provides the ability to process input for hierarchies. - class NetworkHierarchyRootComponentController + class NetworkHierarchyRootComponentController final : public NetworkHierarchyRootComponentControllerBase { public: diff --git a/Gems/Multiplayer/Code/Source/Components/NetworkHierarchyRootComponent.cpp b/Gems/Multiplayer/Code/Source/Components/NetworkHierarchyRootComponent.cpp index dd83878b25..e45389b7d9 100644 --- a/Gems/Multiplayer/Code/Source/Components/NetworkHierarchyRootComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Components/NetworkHierarchyRootComponent.cpp @@ -373,6 +373,8 @@ namespace Multiplayer } NetEntityId childNetEntitydId = networkEntityManager->GetNetEntityIdById(child->GetId()); + AZ_Assert(childNetEntitydId != InvalidNetEntityId, "Unable to find the hierarchy entity in Network Entity Manager"); + ConstNetworkEntityHandle childEntityHandle = networkEntityManager->GetEntity(childNetEntitydId); NetBindComponent* netComp = childEntityHandle.GetNetBindComponent(); @@ -395,24 +397,13 @@ namespace Multiplayer void NetworkHierarchyRootComponentController::ProcessInput(Multiplayer::NetworkInput& input, float deltaTime) { - // Prevent replaying process input commands for child entities that weren't part of the hierarchy at that time - //if (!m_firstProcessInputOccurred) - //{ - // m_firstProcessInputOccurred = true; - // m_firstProcessInputTime = input.GetInputId().GetGameTimePoint(); - //} - //else if (m_firstProcessInputTime > input.GetInputId().GetGameTimePoint()) - //{ - // return; - //} - if (auto* networkInput = input.FindComponentInput()) { INetworkEntityManager* networkEntityManager = AZ::Interface::Get(); AZ_Assert(networkEntityManager, "NetworkEntityManager must be created."); // Build a set of Net IDs for the children - AZStd::unordered_set currentChildren; // TODO: Cache inside the component if this becomes a performance issue. + AZStd::unordered_set currentChildren; NetworkHierarchyRootComponent& component = GetParent(); for (AZ::Entity* child : component.m_hierarchicalEntities) { @@ -420,7 +411,9 @@ namespace Multiplayer { continue; } - NetEntityId childNetEntitydId = networkEntityManager->GetNetEntityIdById(child->GetId()); // TODO: Cache net IDs in the component if this becomes a performance issue + + NetEntityId childNetEntitydId = networkEntityManager->GetNetEntityIdById(child->GetId()); + AZ_Assert(childNetEntitydId != InvalidNetEntityId, "Unable to find the hierarchy entity in Network Entity Manager"); currentChildren.insert(childNetEntitydId); } @@ -468,6 +461,8 @@ namespace Multiplayer } NetEntityId childNetEntitydId = networkEntityManager->GetNetEntityIdById(child->GetId()); + AZ_Assert(childNetEntitydId != InvalidNetEntityId, "Unable to find the hierarchy entity in Network Entity Manager"); + ConstNetworkEntityHandle childEntityHandle = networkEntityManager->GetEntity(childNetEntitydId); NetBindComponent* netBindComponent = childEntityHandle.GetNetBindComponent(); AZ_Assert(netBindComponent, "No NetBindComponent, this should be impossible"); diff --git a/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp b/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp index d8195bf29a..856fd59f9d 100644 --- a/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp +++ b/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp @@ -335,6 +335,8 @@ namespace Multiplayer for (const AZ::Entity* controlledEntity : hierarchyComponent.m_hierarchicalEntities) { NetEntityId controlledNetEntitydId = networkEntityManager->GetNetEntityIdById(controlledEntity->GetId()); + AZ_Assert(controlledNetEntitydId != InvalidNetEntityId, "Unable to find the hierarchy entity in Network Entity Manager"); + ConstNetworkEntityHandle controlledEntityHandle = networkEntityManager->GetEntity(controlledNetEntitydId); AZ_Assert(controlledEntityHandle != nullptr, "We have lost a controlled entity unexpectedly");