Guest User

Untitled

a guest
Nov 9th, 2018
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void MyCustomSystemComponent::AddSpawnSliceRequest(const AZStd::string & sliceName, const AZ::Vector3 & pos)
  2. {
  3.  
  4.     AZ::SimpleLcgRandom m_randomGenerator;
  5.  
  6.     //m_randIndex = m_randomGenerator.GetRandom();
  7.  
  8.     m_spawnPos = AZ::Vector3(
  9.         1024.0f * 0.5f + m_randomGenerator.GetRandomFloat() * (16.0f),
  10.         1024.0f * 0.5f + m_randomGenerator.GetRandomFloat() * (16.0f),
  11.         45.f
  12.     );
  13.  
  14.  
  15.     AZ::Data::AssetId sliceAssetId;
  16.  
  17.     EBUS_EVENT_RESULT(sliceAssetId, AZ::Data::AssetCatalogRequestBus, GetAssetIdByPath, "Slices/DynamicSlice.dynamicslice", AZ::AzTypeInfo<AZ::DynamicPrefabAsset>::Uuid(), true);
  18.  
  19.     if (sliceAssetId.IsValid())
  20.     {
  21.         // Using the valid ID, find the actual slice asset
  22.         AZ::Data::Asset<AZ::DynamicSliceAsset> sliceAsset;
  23.         sliceAsset.Create(sliceAssetId, true);
  24.         if (sliceAsset.GetId().IsValid())
  25.         {
  26.  
  27.             AZ::Transform transform(AZ::Transform::CreateTranslation(m_spawnPos));
  28.             //AzFramework::SliceInstantiationTicket ticket;
  29.             //EBUS_EVENT_RESULT(ticket, AzFramework::GameEntityContextRequestBus, InstantiateDynamicSlice, sliceAsset, transform, nullptr);
  30.  
  31.             LmbrCentral::SpawnerComponentRequestBus::Event(GetEntityId(), &LmbrCentral::SpawnerComponentRequestBus::Events::SpawnSliceAbsolute, sliceAsset, transform);
  32.         }
  33.     }
  34. }
RAW Paste Data