sig/network - bugfix - removal of player prefabs on disconnect

sig/network - bugfix - removal of player prefabs on disconnect
This commit is contained in:
Olex Lozitskiy
2021-06-24 15:01:41 -05:00
committed by GitHub
6 changed files with 30 additions and 22 deletions
@@ -34,7 +34,9 @@ namespace Multiplayer
{
class IEntityDomain;
class EntityReplicator;
//! @class EntityReplicationManager
//! @brief Handles replication of relevant entities for one connection.
class EntityReplicationManager final
{
public:
@@ -277,15 +277,6 @@ namespace Multiplayer
{
//RewindableObjectState::ClearRewoundEntities();
// Keystone has refactored these API's, rewrite required
//AZ::SliceComponent* rootSlice = nullptr;
//{
// AzFramework::EntityContextId gameContextId = AzFramework::EntityContextId::CreateNull();
// AzFramework::GameEntityContextRequestBus::BroadcastResult(gameContextId, &AzFramework::GameEntityContextRequests::GetGameEntityContextId);
// AzFramework::EntityContextRequestBus::BroadcastResult(rootSlice, &AzFramework::EntityContextRequests::GetRootSlice);
// AZ_Assert(rootSlice != nullptr, "Root slice returned was NULL");
//}
AZStd::vector<NetEntityId> removeList;
removeList.swap(m_removeList);
for (NetEntityId entityId : removeList)
@@ -299,13 +290,12 @@ namespace Multiplayer
AZ_Assert(netBindComponent != nullptr, "NetBindComponent not found on networked entity");
netBindComponent->StopEntity();
// Delete Entity, method depends on how it was loaded
// Try slice removal first, then force delete
//AZ::Entity* rawEntity = removeEntity.GetEntity();
//if (!rootSlice->RemoveEntity(rawEntity))
//{
// delete rawEntity;
//}
// At the moment, we spawn one entity at a time and avoid Prefab API calls and never get a spawn ticket,
// so this is the right way for now. Once we support prefabs we can use AzFramework::SpawnableEntitiesContainer
// Additionally, prefabs spawning is async! Whereas we currently create entities immediately, see:
// @NetworkEntityManager::CreateEntitiesImmediate
AzFramework::GameEntityContextRequestBus::Broadcast(
&AzFramework::GameEntityContextRequestBus::Events::DestroyGameEntity, netBindComponent->GetEntityId());
}
m_networkEntityTracker.erase(entityId);
@@ -59,10 +59,11 @@ namespace Multiplayer
NetworkEntityUpdateMessage::NetworkEntityUpdateMessage(NetEntityId entityId, bool wasMigrated, bool takeOwnership)
: m_entityId(entityId)
, m_isDelete(true)
, m_wasMigrated(wasMigrated)
, m_takeOwnership(takeOwnership)
{
;
// this is a delete entity message c-tor
}
NetworkEntityUpdateMessage& NetworkEntityUpdateMessage::operator =(NetworkEntityUpdateMessage&& rhs)