Fixes to sending entity updates and entity rpcs within an environment set up for cross host entity migration

Signed-off-by: kberg-amzn <karlberg@amazon.com>
This commit is contained in:
kberg-amzn
2021-09-28 19:25:04 -07:00
parent 0a829f9661
commit 02bc89cd92
21 changed files with 185 additions and 134 deletions
@@ -7,6 +7,7 @@
*/
#include <Source/ReplicationWindows/ServerToClientReplicationWindow.h>
#include <Source/AutoGen/Multiplayer.AutoPackets.h>
#include <Multiplayer/Components/NetBindComponent.h>
#include <AzFramework/Visibility/IVisibilitySystem.h>
#include <AzCore/Component/TransformBus.h>
@@ -50,7 +51,7 @@ namespace Multiplayer
return m_priority < rhs.m_priority;
}
ServerToClientReplicationWindow::ServerToClientReplicationWindow(NetworkEntityHandle controlledEntity, const AzNetworking::IConnection* connection)
ServerToClientReplicationWindow::ServerToClientReplicationWindow(NetworkEntityHandle controlledEntity, AzNetworking::IConnection* connection)
: m_controlledEntity(controlledEntity)
, m_entityActivatedEventHandler([this](AZ::Entity* entity) { OnEntityActivated(entity); })
, m_entityDeactivatedEventHandler([this](AZ::Entity* entity) { OnEntityDeactivated(entity); })
@@ -179,6 +180,29 @@ namespace Multiplayer
//}
}
AzNetworking::PacketId ServerToClientReplicationWindow::SendEntityUpdateMessages(NetworkEntityUpdateVector& entityUpdateVector)
{
MultiplayerPackets::EntityUpdates entityUpdatePacket;
entityUpdatePacket.SetHostTimeMs(GetNetworkTime()->GetHostTimeMs());
entityUpdatePacket.SetHostFrameId(GetNetworkTime()->GetHostFrameId());
entityUpdatePacket.SetEntityMessages(entityUpdateVector);
return m_connection->SendUnreliablePacket(entityUpdatePacket);
}
void ServerToClientReplicationWindow::SendEntityRpcs(NetworkEntityRpcVector& entityRpcVector, bool reliable)
{
MultiplayerPackets::EntityRpcs entityRpcsPacket;
entityRpcsPacket.SetEntityRpcs(entityRpcVector);
if (reliable)
{
m_connection->SendReliablePacket(entityRpcsPacket);
}
else
{
m_connection->SendUnreliablePacket(entityRpcsPacket);
}
}
void ServerToClientReplicationWindow::DebugDraw() const
{
//static const float BoundaryStripeHeight = 1.0f;