Many fixes for external gem multiplayer components and component network inputs, fixes an uninitialized variable resulting in continual desyncs, restructures our public includes to match the directory structure of source, allows autogen artefacts to be included by external gems, allowing for external multiplayer components to interact with multiplayer gem components with no extra code

This commit is contained in:
karlberg
2021-05-14 14:24:33 -07:00
parent 795aa114e6
commit 5acdc40595
73 changed files with 348 additions and 267 deletions
@@ -10,13 +10,13 @@
*
*/
#include <Multiplayer/NetBindComponent.h>
#include <Multiplayer/NetworkEntityRpcMessage.h>
#include <Multiplayer/NetworkEntityUpdateMessage.h>
#include <Multiplayer/NetworkInput.h>
#include <Multiplayer/INetworkEntityManager.h>
#include <Multiplayer/MultiplayerComponent.h>
#include <Multiplayer/MultiplayerController.h>
#include <Multiplayer/Components/NetBindComponent.h>
#include <Multiplayer/Components/MultiplayerComponent.h>
#include <Multiplayer/Components/MultiplayerController.h>
#include <Multiplayer/NetworkEntity/INetworkEntityManager.h>
#include <Multiplayer/NetworkEntity/NetworkEntityRpcMessage.h>
#include <Multiplayer/NetworkEntity/NetworkEntityUpdateMessage.h>
#include <Multiplayer/NetworkInput/NetworkInput.h>
#include <AzCore/Console/IConsole.h>
#include <AzCore/Console/ILogger.h>
#include <AzCore/Interface/Interface.h>
@@ -110,6 +110,22 @@ namespace Multiplayer
return (m_netEntityRole == NetEntityRole::Authority);
}
bool NetBindComponent::IsAutonomous() const
{
return (m_netEntityRole == NetEntityRole::Autonomous)
|| (m_netEntityRole == NetEntityRole::Authority) && m_allowAutonomy;
}
bool NetBindComponent::IsServer() const
{
return (m_netEntityRole == NetEntityRole::Server);
}
bool NetBindComponent::IsClient() const
{
return (m_netEntityRole == NetEntityRole::Client);
}
bool NetBindComponent::HasController() const
{
return (m_netEntityRole == NetEntityRole::Authority)
@@ -136,14 +152,21 @@ namespace Multiplayer
return m_netEntityHandle;
}
void NetBindComponent::SetAllowAutonomy(bool value)
{
// This flag allows a player host to autonomously control their player entity, even though the entity is in an authority role
m_allowAutonomy = value;
}
MultiplayerComponentInputVector NetBindComponent::AllocateComponentInputs()
{
MultiplayerComponentInputVector componentInputs;
const size_t multiplayerComponentSize = m_multiplayerInputComponentVector.size();
for (size_t i = 0; i < multiplayerComponentSize; ++i)
{
// TODO: ComponentInput factory, needs multiplayer component architecture and autogen
AZStd::unique_ptr<IMultiplayerComponentInput> componentInput = nullptr; // ComponentInputFactory(multiplayerComponent->GetComponentId());
const NetComponentId netComponentId = m_multiplayerInputComponentVector[i]->GetNetComponentId();
AZStd::unique_ptr<IMultiplayerComponentInput> componentInput = AZStd::move(GetMultiplayerComponentRegistry()->AllocateComponentInput(netComponentId));
if (componentInput != nullptr)
{
componentInputs.emplace_back(AZStd::move(componentInput));