Autonomous to Authority Net Properties (#2153)
* WIP. Autonomous->Authority network properties now functional. Still need some research in regards to entity ownership when it comes to the PropertyPublisher. Signed-off-by: Gene Walters <genewalt@amazon.com> * WIP. Exposing Auton->Auth Properties accessors and onchange events Signed-off-by: Gene Walters <genewalt@amazon.com> * Fix propertypublisher constructor to skip the creation state if we arent the owner. Removing ClientToServerReplicationWindow, return to just using NullReplicationWindow. Signed-off-by: Gene Walters <genewalt@amazon.com> * Reverting some wip debug prints Signed-off-by: Gene Walters <genewalt@amazon.com> * Minor whitespacing fix Signed-off-by: Gene Walters <genewalt@amazon.com> * minor undoing of whitespacing Signed-off-by: Gene Walters <genewalt@amazon.com> * NullReplicationWindow MaxReplication is 0, but now Autonomous entity updates will always be added to the send list (ignoring the max replication limit) Signed-off-by: Gene Walters <genewalt@amazon.com> * Updating PropertyPublisher comment to explicitly call out if we dont own the entity locally, the remote replicator must exist Signed-off-by: Gene Walters <genewalt@amazon.com> * Renaming RepiclationWindow GetMaxEntityReplicatorSendCount to GetMaxProxyEntityReplicatorSendCount; this number only affects the number of proxy sends and allows autonomous properties to always send Signed-off-by: Gene Walters <genewalt@amazon.com>
This commit is contained in:
+9
-13
@@ -185,16 +185,14 @@ namespace Multiplayer
|
||||
// Generate a list of all our entities that need updates
|
||||
EntityReplicatorList toSendList;
|
||||
|
||||
uint32_t elementsAdded = 0;
|
||||
for (auto iter = m_replicatorsPendingSend.begin(); iter != m_replicatorsPendingSend.end() && elementsAdded < m_replicationWindow->GetMaxEntityReplicatorSendCount(); )
|
||||
uint32_t proxySendCount = 0;
|
||||
for (auto iter = m_replicatorsPendingSend.begin(); iter != m_replicatorsPendingSend.end();)
|
||||
{
|
||||
EntityReplicator* replicator = GetEntityReplicator(*iter);
|
||||
bool clearPendingSend = true;
|
||||
if (replicator)
|
||||
if (EntityReplicator* replicator = GetEntityReplicator(*iter))
|
||||
{
|
||||
NetEntityId entityId = replicator->GetEntityHandle().GetNetEntityId();
|
||||
PropertyPublisher* propPublisher = replicator->GetPropertyPublisher();
|
||||
if (propPublisher)
|
||||
if (PropertyPublisher* propPublisher = replicator->GetPropertyPublisher())
|
||||
{
|
||||
// don't have too many replicators pending creation outstanding at a time
|
||||
bool canSend = true;
|
||||
@@ -220,19 +218,17 @@ namespace Multiplayer
|
||||
m_remoteEntitiesPendingCreation.insert(entityId);
|
||||
}
|
||||
|
||||
if (replicator->GetRemoteNetworkRole() == NetEntityRole::Autonomous)
|
||||
if (replicator->GetRemoteNetworkRole() == NetEntityRole::Autonomous ||
|
||||
replicator->GetBoundLocalNetworkRole() == NetEntityRole::Autonomous)
|
||||
{
|
||||
toSendList.push_back(replicator);
|
||||
}
|
||||
else
|
||||
else if (proxySendCount < m_replicationWindow->GetMaxProxyEntityReplicatorSendCount())
|
||||
{
|
||||
if (elementsAdded < m_replicationWindow->GetMaxEntityReplicatorSendCount())
|
||||
{
|
||||
toSendList.push_back(replicator);
|
||||
}
|
||||
toSendList.push_back(replicator);
|
||||
++proxySendCount;
|
||||
}
|
||||
}
|
||||
++elementsAdded;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -305,16 +305,12 @@ namespace Multiplayer
|
||||
|
||||
bool EntityReplicator::RemoteManagerOwnsEntityLifetime() const
|
||||
{
|
||||
bool ret(false);
|
||||
bool isServer = (GetBoundLocalNetworkRole() == NetEntityRole::Server)
|
||||
&& (GetRemoteNetworkRole() == NetEntityRole::Authority);
|
||||
bool isClient = (GetBoundLocalNetworkRole() == NetEntityRole::Client)
|
||||
|| (GetBoundLocalNetworkRole() == NetEntityRole::Autonomous);
|
||||
if (isServer || isClient)
|
||||
{
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
|
||||
return isServer || isClient;
|
||||
}
|
||||
|
||||
void EntityReplicator::MarkForRemoval()
|
||||
|
||||
@@ -22,6 +22,14 @@ namespace Multiplayer
|
||||
, m_pendingRecord(remoteNetworkRole)
|
||||
, m_sentRecords(net_EntityReplicatorRecordsMax)
|
||||
{
|
||||
if ( ownsLifetime == OwnsLifetime::False )
|
||||
{
|
||||
// This entity is owned by some other authority; this publisher will only be used for updating (not creating).
|
||||
// Since this replicator does not own it's lifetime, the remote replicator must exist (otherwise, we would never have created a replicator that doesn't own its lifetime).
|
||||
m_remoteReplicatorEstablished = true;
|
||||
m_replicatorState = EntityReplicatorState::Updating;
|
||||
}
|
||||
|
||||
AZ_Assert(m_netBindComponent, "NetBindComponent is nullptr");
|
||||
m_pendingRecord.SetRemoteNetworkRole(remoteNetworkRole);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user