MCPcopy Create free account
hub / github.com/Illation/ETEngine / GetAsset

Method GetAsset

Engine/source/EtCore/Content/AssetDatabase.cpp:193–216  ·  view source on GitHub ↗

--------------------------------- AssetDatabase::GetAsset Get an asset by its ID

Source from the content-addressed store, hash-verified

191// Get an asset by its ID
192//
193I_Asset* AssetDatabase::GetAsset(HashString const assetId, bool const reportErrors) const
194{
195 // in this version we loop over all caches
196 for (AssetCache const& cache : caches)
197 {
198 // try finding our asset by its ID in the cache
199 auto foundAssetIt = std::find_if(cache.cache.begin(), cache.cache.end(), [assetId](I_Asset* asset)
200 {
201 return asset->GetId() == assetId;
202 });
203
204 if (foundAssetIt != cache.cache.cend())
205 {
206 return *foundAssetIt;
207 }
208 }
209
210 // didn't find an asset in any cache, return null
211 if (reportErrors)
212 {
213 ET_ASSERT(false, "Couldn't find asset with ID '%s'!", assetId.ToStringDbg());
214 }
215 return nullptr;
216}
217
218//---------------------------------
219// AssetDatabase::GetAsset

Callers

nothing calls this directly

Calls 5

beginMethod · 0.80
endMethod · 0.80
ToStringDbgMethod · 0.80
GetIdMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected