Improved comments and minor changes to accessing interfaces
Signed-off-by: srikappa-amzn <srikappa@amazon.com>
This commit is contained in:
@@ -290,7 +290,10 @@ namespace AzFramework
|
||||
isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
|
||||
if (isPrefabSystemEnabled)
|
||||
{
|
||||
AZ::Interface<SpawnedEntityTicketMapperInterface>::Get()->RemoveSpawnedEntity(currentEntity->GetId());
|
||||
SpawnedEntityTicketMapperInterface* spawnedEntityTicketMapperInterface =
|
||||
AZ::Interface<SpawnedEntityTicketMapperInterface>::Get();
|
||||
AZ_Assert(spawnedEntityTicketMapperInterface != nullptr, "SpawnedEntityTicketMapperInterface is not found.");
|
||||
spawnedEntityTicketMapperInterface->RemoveSpawnedEntity(currentEntity->GetId());
|
||||
}
|
||||
|
||||
if (currentEntity->GetState() == AZ::Entity::State::Active)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <AzFramework/Entity/GameEntityContextBus.h>
|
||||
#include <AzFramework/Spawnable/Spawnable.h>
|
||||
#include <AzFramework/Spawnable/SpawnableEntitiesManager.h>
|
||||
#include <AzFramework/Spawnable/SpawnedEntityTicketMapperInterface.h>
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
@@ -352,7 +351,7 @@ namespace AzFramework
|
||||
for (auto it = ticket.m_spawnedEntities.begin() + spawnedEntitiesInitialCount; it != ticket.m_spawnedEntities.end(); ++it)
|
||||
{
|
||||
GameEntityContextRequestBus::Broadcast(&GameEntityContextRequestBus::Events::AddGameEntity, *it);
|
||||
AZ::Interface<SpawnedEntityTicketMapperInterface>::Get()->AddSpawnedEntity((*it)->GetId(), &ticket);
|
||||
m_spawnedEntityTicketMapper.AddSpawnedEntity((*it)->GetId(), &ticket);
|
||||
}
|
||||
|
||||
// Let other systems know about newly spawned entities for any post-processing after adding to the scene/game context.
|
||||
@@ -434,7 +433,7 @@ namespace AzFramework
|
||||
for (auto it = ticket.m_spawnedEntities.begin() + spawnedEntitiesInitialCount; it != ticket.m_spawnedEntities.end(); ++it)
|
||||
{
|
||||
GameEntityContextRequestBus::Broadcast(&GameEntityContextRequestBus::Events::AddGameEntity, *it);
|
||||
AZ::Interface<SpawnedEntityTicketMapperInterface>::Get()->AddSpawnedEntity((*it)->GetId(), &ticket);
|
||||
m_spawnedEntityTicketMapper.AddSpawnedEntity((*it)->GetId(), &ticket);
|
||||
}
|
||||
|
||||
if (request.m_completionCallback)
|
||||
@@ -625,18 +624,18 @@ namespace AzFramework
|
||||
|
||||
bool SpawnableEntitiesManager::ProcessRequest(ClaimEntityCommand& request)
|
||||
{
|
||||
Ticket& ticket = *request.m_ticket;
|
||||
if (request.m_requestId == ticket.m_currentRequestId)
|
||||
Ticket* ticket = request.m_ticket;
|
||||
if (request.m_requestId == ticket->m_currentRequestId)
|
||||
{
|
||||
AZStd::vector<AZ::Entity*>& spawnedEntities = ticket.m_spawnedEntities;
|
||||
AZStd::vector<AZ::Entity*>& spawnedEntities = ticket->m_spawnedEntities;
|
||||
AZStd::vector<AZ::Entity*>::size_type entityIndex = 0;
|
||||
for (entityIndex = 0; entityIndex < spawnedEntities.size(); entityIndex++)
|
||||
{
|
||||
if (spawnedEntities[entityIndex]->GetId() == request.m_entityId)
|
||||
{
|
||||
spawnedEntities.erase(spawnedEntities.begin() + entityIndex);
|
||||
ticket.m_spawnedEntityIndices.erase(ticket.m_spawnedEntityIndices.begin() + entityIndex);
|
||||
ticket.m_currentRequestId++;
|
||||
ticket->m_spawnedEntityIndices.erase(ticket->m_spawnedEntityIndices.begin() + entityIndex);
|
||||
ticket->m_currentRequestId++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/std/containers/vector.h>
|
||||
#include <AzCore/std/parallel/mutex.h>
|
||||
#include <AzFramework/Spawnable/SpawnableEntitiesInterface.h>
|
||||
#include <AzFramework/Spawnable/SpawnedEntityTicketMapper.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -167,7 +168,6 @@ namespace AzFramework
|
||||
struct ClaimEntityCommand
|
||||
{
|
||||
Ticket* m_ticket;
|
||||
EntitySpawnTicket::Id m_ticketId;
|
||||
uint32_t m_requestId;
|
||||
AZ::EntityId m_entityId;
|
||||
};
|
||||
@@ -234,6 +234,8 @@ namespace AzFramework
|
||||
//! SpawnablePriority_Default which gives users a bit of room to fine tune the priorities as this value can be configured
|
||||
//! through the Settings Registry under the key "/O3DE/AzFramework/Spawnables/HighPriorityThreshold".
|
||||
SpawnablePriority m_highPriorityThreshold { 64 };
|
||||
private:
|
||||
SpawnedEntityTicketMapper m_spawnedEntityTicketMapper;
|
||||
};
|
||||
|
||||
AZ_DEFINE_ENUM_BITWISE_OPERATORS(AzFramework::SpawnableEntitiesManager::CommandQueuePriority);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <AzFramework/Spawnable/SpawnableAssetHandler.h>
|
||||
#include <AzFramework/Spawnable/SpawnableEntitiesContainer.h>
|
||||
#include <AzFramework/Spawnable/SpawnableEntitiesManager.h>
|
||||
#include <AzFramework/Spawnable/SpawnedEntityTicketMapper.h>
|
||||
|
||||
namespace AzFramework
|
||||
{
|
||||
@@ -91,7 +90,6 @@ namespace AzFramework
|
||||
void LoadRootSpawnableFromSettingsRegistry();
|
||||
|
||||
SpawnableAssetHandler m_assetHandler;
|
||||
SpawnedEntityTicketMapper m_spawnedEntityTicketMapper;
|
||||
SpawnableEntitiesManager m_entitiesManager;
|
||||
SpawnableEntitiesContainer m_rootSpawnableContainer;
|
||||
AZ::SettingsRegistryInterface::NotifyEventHandler m_registryChangeHandler;
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace AzFramework
|
||||
{
|
||||
SpawnedEntityTicketMapper::SpawnedEntityTicketMapper()
|
||||
{
|
||||
spawnableEntitiesInterface = SpawnableEntitiesInterface::Get();
|
||||
AZ_Assert(spawnableEntitiesInterface != nullptr, "SpawnableEntitiesInterface is not found.");
|
||||
|
||||
AZ::Interface<SpawnedEntityTicketMapperInterface>::Register(this);
|
||||
}
|
||||
|
||||
@@ -26,8 +29,6 @@ namespace AzFramework
|
||||
auto spawnedGameEntitiesIterator = m_spawnedEntities.find(entityId);
|
||||
if (spawnedGameEntitiesIterator != m_spawnedEntities.end())
|
||||
{
|
||||
SpawnableEntitiesDefinition* spawnableEntitiesInterface = SpawnableEntitiesInterface::Get();
|
||||
AZ_Assert(spawnableEntitiesInterface == nullptr, "SpawnableEntitiesInterface is not found.");
|
||||
spawnableEntitiesInterface->ClaimEntity(
|
||||
spawnedGameEntitiesIterator->first, spawnedGameEntitiesIterator->second);
|
||||
m_spawnedEntities.erase(entityId);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace AzFramework
|
||||
SpawnedEntityTicketMapper();
|
||||
~SpawnedEntityTicketMapper();
|
||||
|
||||
//! Removes the entityId from the spawned entities map.
|
||||
//! Removes the entityId from the spawned entities map if present.
|
||||
//! @param entityId The id of the entity to remove.
|
||||
void RemoveSpawnedEntity(AZ::EntityId entityId) override;
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace AzFramework
|
||||
//! @param ticket The ticket pointer to add.
|
||||
void AddSpawnedEntity(AZ::EntityId entityId, void* ticket) override;
|
||||
private:
|
||||
SpawnableEntitiesDefinition* spawnableEntitiesInterface = nullptr;
|
||||
AZStd::unordered_map<AZ::EntityId, void*> m_spawnedEntities;
|
||||
};
|
||||
} // namespace AzFramework
|
||||
|
||||
Reference in New Issue
Block a user