Minor updates to the Spawnable Entity Aliases in response to PR feedback.

Signed-off-by: AMZN-koppersr <82230785+AMZN-koppersr@users.noreply.github.com>
This commit is contained in:
AMZN-koppersr
2022-01-05 10:47:23 -08:00
parent 34edd4d0c0
commit 31e51f8c3a
3 changed files with 9 additions and 5 deletions
@@ -101,6 +101,8 @@ namespace UnitTest
class SpawnableEntitiesManagerTest : public AllocatorsFixture
{
public:
constexpr static AZ::u64 EntityIdStartId = 40;
void SetUp() override
{
AllocatorsFixture::SetUp();
@@ -156,7 +158,7 @@ namespace UnitTest
{
auto entry = AZStd::make_unique<AZ::Entity>();
entry->AddComponent(aznew SourceSpawnableComponent());
entry->SetId(AZ::EntityId(40 + i));
entry->SetId(AZ::EntityId(EntityIdStartId + i));
entities.push_back(AZStd::move(entry));
}
}
@@ -175,13 +177,13 @@ namespace UnitTest
auto entry = AZStd::make_unique<AZ::Entity>();
if (i != 0)
{
entry->AddComponent(aznew TargetSpawnableComponent(AZ::EntityId(40 + i - 1)));
entry->AddComponent(aznew TargetSpawnableComponent(AZ::EntityId(EntityIdStartId + i - 1)));
}
else
{
entry->AddComponent(aznew TargetSpawnableComponent());
}
entry->SetId(AZ::EntityId(40 + i));
entry->SetId(AZ::EntityId(EntityIdStartId + i));
entities.push_back(AZStd::move(entry));
}
}
@@ -415,8 +415,7 @@ namespace AzToolsFramework
{
// Construct the runtime entities and products
bool readyToCreateRootSpawnable = m_playInEditorData.m_assetsCache.IsActivated();
if (!readyToCreateRootSpawnable &&
!m_playInEditorData.m_assetsCache.Activate(Prefab::PrefabConversionUtils::PlayInEditor))
if (!readyToCreateRootSpawnable && !m_playInEditorData.m_assetsCache.Activate(Prefab::PrefabConversionUtils::PlayInEditor))
{
AZ_Error("Prefab", false, "Failed to create a prefab processing stack from key '%.*s'.", AZ_STRING_ARG(Prefab::PrefabConversionUtils::PlayInEditor));
@@ -38,6 +38,7 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
if (!m_prefabNames.contains(name))
{
m_prefabNames.emplace(AZStd::move(name));
// If currently iterating add to pending queue to avoid invalidating the container that's being iterated over.
PrefabContainer& container = m_isIterating ? m_pendingPrefabAdditions : m_prefabs;
container.push_back(AZStd::move(document));
return true;
@@ -47,6 +48,8 @@ namespace AzToolsFramework::Prefab::PrefabConversionUtils
void PrefabProcessorContext::ListPrefabs(const AZStd::function<void(PrefabDocument&)>& callback)
{
// Enable iterating state so the prefab container doesn't get invalided. Enabling this flag will cause new prefabs
// to be stored in a temporary buffer that can be moved into the regular prefab container after iterating.
m_isIterating = true;
for (PrefabDocument& document : m_prefabs)
{