Added "IsReadyToSpawn" to help detect when a spawner is ready to start spawning. Also added a small optimization to SetDynamicSliceByAssetId so that it doesn't do anything when setting it to the same value as before.
(cherry picked from commit ff8a93e71f3017e8555012855f3e2155ec74a405)
This commit is contained in:
@@ -148,6 +148,7 @@ namespace LmbrCentral
|
||||
->Event("GetCurrentEntitiesFromSpawnedSlice", &SpawnerComponentRequestBus::Events::GetCurrentEntitiesFromSpawnedSlice)
|
||||
->Event("GetAllCurrentlySpawnedEntities", &SpawnerComponentRequestBus::Events::GetAllCurrentlySpawnedEntities)
|
||||
->Event("SetDynamicSlice", &SpawnerComponentRequestBus::Events::SetDynamicSliceByAssetId)
|
||||
->Event("IsReadyToSpawn", &SpawnerComponentRequestBus::Events::IsReadyToSpawn)
|
||||
;
|
||||
|
||||
behaviorContext->EBus<SpawnerComponentNotificationBus>("SpawnerComponentNotificationBus")
|
||||
@@ -250,17 +251,15 @@ namespace LmbrCentral
|
||||
//=========================================================================
|
||||
void SpawnerComponent::SetDynamicSliceByAssetId(AZ::Data::AssetId& assetId)
|
||||
{
|
||||
auto sliceAsset = AZ::Data::AssetManager::Instance().GetAsset(assetId, AZ::AzTypeInfo<AZ::DynamicSliceAsset>::Uuid(), m_sliceAsset.GetAutoLoadBehavior());
|
||||
if (m_sliceAsset.GetId() == assetId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (sliceAsset.IsReady())
|
||||
{
|
||||
m_sliceAsset = sliceAsset;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ::Data::AssetBus::Handler::BusDisconnect();
|
||||
AZ::Data::AssetBus::Handler::BusConnect(assetId);
|
||||
}
|
||||
m_sliceAsset = AZ::Data::AssetManager::Instance().GetAsset(
|
||||
assetId, AZ::AzTypeInfo<AZ::DynamicSliceAsset>::Uuid(), m_sliceAsset.GetAutoLoadBehavior());
|
||||
AZ::Data::AssetBus::Handler::BusDisconnect();
|
||||
AZ::Data::AssetBus::Handler::BusConnect(assetId);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -444,6 +443,12 @@ namespace LmbrCentral
|
||||
return entities;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
bool SpawnerComponent::IsReadyToSpawn()
|
||||
{
|
||||
return m_sliceAsset.IsReady();
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
void SpawnerComponent::OnSlicePreInstantiate(const AZ::Data::AssetId& /*sliceAssetId*/, [[maybe_unused]] const AZ::SliceComponent::SliceInstanceAddress& sliceAddress)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user