Fix a comment and minor optimization to the server to client replication window
This commit is contained in:
+1
-1
@@ -71,7 +71,7 @@ namespace AzFramework
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzFramework);
|
||||
|
||||
// ignore any entity that might activate which does not have a TransformComponent
|
||||
// ignore any entity that might deactivate which does not have a TransformComponent
|
||||
if (entity->GetTransform() == nullptr)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -56,6 +56,8 @@ namespace Multiplayer
|
||||
|
||||
ServerToClientReplicationWindow::ServerToClientReplicationWindow(NetworkEntityHandle controlledEntity, const AzNetworking::IConnection* connection)
|
||||
: m_controlledEntity(controlledEntity)
|
||||
, m_entityActivatedEventHandler([this](AZ::Entity* entity) { OnEntityActivated(entity); })
|
||||
, m_entityDeactivatedEventHandler([this](AZ::Entity* entity) { OnEntityDeactivated(entity); })
|
||||
, m_connection(connection)
|
||||
, m_lastCheckedSentPackets(connection->GetMetrics().m_packetsSent)
|
||||
, m_lastCheckedLostPackets(connection->GetMetrics().m_packetsLost)
|
||||
@@ -74,7 +76,9 @@ namespace Multiplayer
|
||||
//}
|
||||
|
||||
m_updateWindowEvent.Enqueue(sv_ClientReplicationWindowUpdateMs, true);
|
||||
AZ::EntitySystemBus::Handler::BusConnect();
|
||||
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Get()->RegisterEntityActivatedEventHandler(m_entityActivatedEventHandler);
|
||||
AZ::Interface<AZ::ComponentApplicationRequests>::Get()->RegisterEntityDeactivatedEventHandler(m_entityDeactivatedEventHandler);
|
||||
}
|
||||
|
||||
bool ServerToClientReplicationWindow::ReplicationSetUpdateReady()
|
||||
@@ -205,10 +209,8 @@ namespace Multiplayer
|
||||
//}
|
||||
}
|
||||
|
||||
void ServerToClientReplicationWindow::OnEntityActivated(const AZ::EntityId& entityId)
|
||||
void ServerToClientReplicationWindow::OnEntityActivated(AZ::Entity* entity)
|
||||
{
|
||||
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(entityId);
|
||||
|
||||
ConstNetworkEntityHandle entityHandle(entity, GetNetworkEntityTracker());
|
||||
NetBindComponent* netBindComponent = entityHandle.GetNetBindComponent();
|
||||
if (netBindComponent != nullptr)
|
||||
@@ -236,10 +238,8 @@ namespace Multiplayer
|
||||
}
|
||||
}
|
||||
|
||||
void ServerToClientReplicationWindow::OnEntityDeactivated(const AZ::EntityId& entityId)
|
||||
void ServerToClientReplicationWindow::OnEntityDeactivated(AZ::Entity* entity)
|
||||
{
|
||||
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(entityId);
|
||||
|
||||
ConstNetworkEntityHandle entityHandle(entity, GetNetworkEntityTracker());
|
||||
NetBindComponent* netBindComponent = entityHandle.GetNetBindComponent();
|
||||
if (netBindComponent != nullptr)
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Multiplayer
|
||||
|
||||
class ServerToClientReplicationWindow
|
||||
: public IReplicationWindow
|
||||
, public AZ::EntitySystemBus::Handler
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -56,11 +55,8 @@ namespace Multiplayer
|
||||
//! @}
|
||||
|
||||
private:
|
||||
//! EntitySystemBus interface
|
||||
//! @{
|
||||
void OnEntityActivated(const AZ::EntityId&) override;
|
||||
void OnEntityDeactivated(const AZ::EntityId&) override;
|
||||
//! @}
|
||||
void OnEntityActivated(AZ::Entity* entity);
|
||||
void OnEntityDeactivated(AZ::Entity* entity);
|
||||
|
||||
//void CollectControlledEntitiesRecursive(ReplicationSet& replicationSet, EntityHierarchyComponent::Authority& hierarchyController);
|
||||
//void OnAddFilteredEntity(NetEntityId filteredEntityId);
|
||||
@@ -79,6 +75,9 @@ namespace Multiplayer
|
||||
NetworkEntityHandle m_controlledEntity;
|
||||
AZ::TransformInterface* m_controlledEntityTransform = nullptr;
|
||||
|
||||
AZ::EntityActivatedEvent::Handler m_entityActivatedEventHandler;
|
||||
AZ::EntityDeactivatedEvent::Handler m_entityDeactivatedEventHandler;
|
||||
|
||||
//FilteredEntityComponent::Authority* m_controlledFilteredEntityComponent = nullptr;
|
||||
//NetBindComponent* m_controlledNetBindComponent = nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user