--------------------------------- AssetDatabase::GetAsset Get an asset by its ID
| 191 | // Get an asset by its ID |
| 192 | // |
| 193 | I_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 |
nothing calls this directly
no test coverage detected