Added optional activation of selective entities spawning

main
pereslav 5 years ago
parent 62564e68de
commit c920e98da7

@ -70,6 +70,12 @@ namespace Multiplayer
True
};
enum class AutoActivate : uint8_t
{
DoNotActivate,
Activate
};
// This is just a placeholder
// The level/prefab cooking will devise the actual solution for identifying a dynamically spawnable entity within a prefab
struct PrefabEntityId

@ -542,11 +542,8 @@ namespace Multiplayer
// Create an entity if we don't have one
if (createEntity)
{
// @pereslav
//replicatorEntity = GetNetworkEntityManager()->CreateSingleEntityImmediateInternal(prefabEntityId, EntitySpawnType::Replicate, AutoActivate::DoNotActivate, netEntityId, localNetworkRole, AZ::Transform::Identity());
INetworkEntityManager::EntityList entityList = GetNetworkEntityManager()->CreateEntitiesImmediate(
prefabEntityId, netEntityId, localNetworkRole,
AZ::Transform::Identity());
prefabEntityId, netEntityId, localNetworkRole, AutoActivate::DoNotActivate, AZ::Transform::Identity());
if (entityList.size() == 1)
{

@ -55,7 +55,8 @@ namespace Multiplayer
//! Creates new entities of the given archetype
//! @param prefabEntryId the name of the spawnable to spawn
virtual EntityList CreateEntitiesImmediate(
const PrefabEntityId& prefabEntryId, NetEntityId netEntityId, NetEntityRole netEntityRole, const AZ::Transform& transform) = 0;
const PrefabEntityId& prefabEntryId, NetEntityId netEntityId, NetEntityRole netEntityRole, AutoActivate autoActivate,
const AZ::Transform& transform) = 0;
//! Returns an ConstEntityPtr for the provided entityId.
//! @param netEntityId the netEntityId to get an ConstEntityPtr for

@ -356,7 +356,7 @@ namespace Multiplayer
INetworkEntityManager::EntityList NetworkEntityManager::CreateEntitiesImmediate(
const PrefabEntityId& prefabEntryId, NetEntityId netEntityId, NetEntityRole netEntityRole,
const AZ::Transform& transform)
AutoActivate autoActivate, const AZ::Transform& transform)
{
INetworkEntityManager::EntityList returnList;
@ -402,6 +402,11 @@ namespace Multiplayer
transformComponent->SetWorldTM(transform);
}
if (autoActivate == AutoActivate::DoNotActivate)
{
clone->SetRuntimeActiveByDefault(false);
}
AzFramework::GameEntityContextRequestBus::Broadcast(
&AzFramework::GameEntityContextRequestBus::Events::AddGameEntity, clone);

@ -49,7 +49,7 @@ namespace Multiplayer
EntityList CreateEntitiesImmediate(
const PrefabEntityId& prefabEntryId, NetEntityId netEntityId, NetEntityRole netEntityRole,
const AZ::Transform& transform) override;
AutoActivate autoActivate, const AZ::Transform& transform) override;
uint32_t GetEntityCount() const override;
NetworkEntityHandle AddEntityToEntityMap(NetEntityId netEntityId, AZ::Entity* entity) override;

Loading…
Cancel
Save