Merge branch 'development' into cmake/linux_fix_warn_unused
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -73,6 +73,11 @@ namespace Multiplayer
|
||||
return m_networkEntityTracker.Get(netEntityId);
|
||||
}
|
||||
|
||||
NetEntityId NetworkEntityManager::GetNetEntityIdById(const AZ::EntityId& entityId) const
|
||||
{
|
||||
return m_networkEntityTracker.Get(entityId);
|
||||
}
|
||||
|
||||
uint32_t NetworkEntityManager::GetEntityCount() const
|
||||
{
|
||||
return static_cast<uint32_t>(m_networkEntityTracker.size());
|
||||
@@ -304,7 +309,7 @@ namespace Multiplayer
|
||||
}
|
||||
|
||||
INetworkEntityManager::EntityList NetworkEntityManager::CreateEntitiesImmediate(
|
||||
const AzFramework::Spawnable& spawnable, NetEntityRole netEntityRole)
|
||||
const AzFramework::Spawnable& spawnable, NetEntityRole netEntityRole, AutoActivate autoActivate)
|
||||
{
|
||||
INetworkEntityManager::EntityList returnList;
|
||||
|
||||
@@ -354,6 +359,11 @@ namespace Multiplayer
|
||||
const NetEntityId netEntityId = NextId();
|
||||
netBindComponent->PreInit(clone, prefabEntityId, netEntityId, netEntityRole);
|
||||
|
||||
if (autoActivate == AutoActivate::DoNotActivate)
|
||||
{
|
||||
clone->SetRuntimeActiveByDefault(false);
|
||||
}
|
||||
|
||||
AzFramework::GameEntityContextRequestBus::Broadcast(
|
||||
&AzFramework::GameEntityContextRequestBus::Events::AddGameEntity, clone);
|
||||
|
||||
@@ -373,10 +383,11 @@ namespace Multiplayer
|
||||
(
|
||||
const PrefabEntityId& prefabEntryId,
|
||||
NetEntityRole netEntityRole,
|
||||
const AZ::Transform& transform
|
||||
const AZ::Transform& transform,
|
||||
AutoActivate autoActivate
|
||||
)
|
||||
{
|
||||
return CreateEntitiesImmediate(prefabEntryId, NextId(), netEntityRole, AutoActivate::Activate, transform);
|
||||
return CreateEntitiesImmediate(prefabEntryId, NextId(), netEntityRole, autoActivate, transform);
|
||||
}
|
||||
|
||||
INetworkEntityManager::EntityList NetworkEntityManager::CreateEntitiesImmediate
|
||||
@@ -409,7 +420,7 @@ namespace Multiplayer
|
||||
|
||||
if (entityIndex == PrefabEntityId::AllIndices)
|
||||
{
|
||||
return CreateEntitiesImmediate(*netSpawnable, netEntityRole);
|
||||
return CreateEntitiesImmediate(*netSpawnable, netEntityRole, autoActivate);
|
||||
}
|
||||
|
||||
const AzFramework::Spawnable::EntityList& entities = netSpawnable->GetEntities();
|
||||
|
||||
@@ -41,13 +41,15 @@ namespace Multiplayer
|
||||
MultiplayerComponentRegistry* GetMultiplayerComponentRegistry() override;
|
||||
HostId GetHostId() const override;
|
||||
ConstNetworkEntityHandle GetEntity(NetEntityId netEntityId) const override;
|
||||
NetEntityId GetNetEntityIdById(const AZ::EntityId& entityId) const override;
|
||||
|
||||
EntityList CreateEntitiesImmediate(const AzFramework::Spawnable& spawnable, NetEntityRole netEntityRole);
|
||||
EntityList CreateEntitiesImmediate(const AzFramework::Spawnable& spawnable, NetEntityRole netEntityRole, AutoActivate autoActivate);
|
||||
EntityList CreateEntitiesImmediate
|
||||
(
|
||||
const PrefabEntityId& prefabEntryId,
|
||||
NetEntityRole netEntityRole,
|
||||
const AZ::Transform& transform
|
||||
const AZ::Transform& transform,
|
||||
AutoActivate autoActivate = AutoActivate::Activate
|
||||
) override;
|
||||
EntityList CreateEntitiesImmediate
|
||||
(
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Multiplayer
|
||||
++m_addChangeDirty;
|
||||
AZ_Assert(m_entityMap.end() == m_entityMap.find(netEntityId), "Attempting to add the same entity to the entity map multiple times");
|
||||
m_entityMap[netEntityId] = entity;
|
||||
m_netEntityIdMap[entity->GetId()] = netEntityId;
|
||||
}
|
||||
|
||||
NetworkEntityHandle NetworkEntityTracker::Get(NetEntityId netEntityId)
|
||||
@@ -32,6 +33,16 @@ namespace Multiplayer
|
||||
return ConstNetworkEntityHandle(entity, netEntityId, this);
|
||||
}
|
||||
|
||||
NetEntityId NetworkEntityTracker::Get(const AZ::EntityId& entityId) const
|
||||
{
|
||||
auto found = m_netEntityIdMap.find(entityId);
|
||||
if (found != m_netEntityIdMap.end())
|
||||
{
|
||||
return found->second;
|
||||
}
|
||||
return Multiplayer::InvalidNetEntityId;
|
||||
}
|
||||
|
||||
bool NetworkEntityTracker::Exists(NetEntityId netEntityId) const
|
||||
{
|
||||
return (m_entityMap.find(netEntityId) != m_entityMap.end());
|
||||
@@ -50,12 +61,22 @@ namespace Multiplayer
|
||||
void NetworkEntityTracker::erase(NetEntityId netEntityId)
|
||||
{
|
||||
++m_deleteChangeDirty;
|
||||
m_entityMap.erase(netEntityId);
|
||||
|
||||
auto found = m_entityMap.find(netEntityId);
|
||||
if (found != m_entityMap.end())
|
||||
{
|
||||
m_netEntityIdMap.erase(found->second->GetId());
|
||||
m_entityMap.erase(found);
|
||||
}
|
||||
}
|
||||
|
||||
NetworkEntityTracker::EntityMap::iterator NetworkEntityTracker::erase(EntityMap::iterator iter)
|
||||
{
|
||||
++m_deleteChangeDirty;
|
||||
if (iter != m_entityMap.end())
|
||||
{
|
||||
m_netEntityIdMap.erase(iter->second->GetId());
|
||||
}
|
||||
return m_entityMap.erase(iter);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Multiplayer
|
||||
public:
|
||||
|
||||
using EntityMap = AZStd::unordered_map<NetEntityId, AZ::Entity*>;
|
||||
using NetEntityIdMap = AZStd::unordered_map<AZ::EntityId, NetEntityId>;
|
||||
using iterator = EntityMap::iterator;
|
||||
using const_iterator = EntityMap::const_iterator;
|
||||
|
||||
@@ -36,6 +37,8 @@ namespace Multiplayer
|
||||
NetworkEntityHandle Get(NetEntityId netEntityId);
|
||||
ConstNetworkEntityHandle Get(NetEntityId netEntityId) const;
|
||||
|
||||
NetEntityId Get(const AZ::EntityId& entityId) const;
|
||||
|
||||
//! Returns true if the netEntityId exists.
|
||||
bool Exists(NetEntityId netEntityId) const;
|
||||
|
||||
@@ -74,6 +77,7 @@ namespace Multiplayer
|
||||
private:
|
||||
|
||||
EntityMap m_entityMap;
|
||||
NetEntityIdMap m_netEntityIdMap;
|
||||
uint32_t m_deleteChangeDirty = 0;
|
||||
uint32_t m_addChangeDirty = 0;
|
||||
};
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace Multiplayer
|
||||
inline void NetworkEntityTracker::clear()
|
||||
{
|
||||
m_entityMap.clear();
|
||||
m_netEntityIdMap.clear();
|
||||
}
|
||||
|
||||
inline uint32_t NetworkEntityTracker::GetChangeDirty(const AZ::Entity* entity) const
|
||||
|
||||
Reference in New Issue
Block a user