Add Content.Stats for assets statistics (replaces Content.AssetCount)

This commit is contained in:
Wojtek Figat
2021-07-07 09:52:37 +02:00
parent 6471f880ac
commit 7985196155
2 changed files with 35 additions and 8 deletions

View File

@@ -360,6 +360,25 @@ String Content::CreateTemporaryAssetPath()
return Globals::TemporaryFolder / (Guid::New().ToString(Guid::FormatType::N) + ASSET_FILES_EXTENSION_WITH_DOT);
}
ContentStats Content::GetStats()
{
ContentStats stats;
AssetsLocker.Lock();
stats.AssetsCount = Assets.Count();
for (auto& e : Assets)
{
if (e.Value->IsLoaded())
stats.LoadedAssetsCount++;
else if (e.Value->LastLoadFailed())
stats.LoadingAssetsCount++;
if (e.Value->IsVirtual())
stats.VirtualAssetsCount++;
}
stats.LoadingAssetsCount = stats.AssetsCount - stats.LoadingAssetsCount - stats.LoadedAssetsCount;
AssetsLocker.Unlock();
return stats;
}
Asset* Content::LoadAsyncInternal(const StringView& internalPath, MClass* type)
{
CHECK_RETURN(type, nullptr);
@@ -430,11 +449,6 @@ Asset* Content::LoadAsync(const StringView& path, const ScriptingTypeHandle& typ
return nullptr;
}
int32 Content::GetAssetCount()
{
return Assets.Count();
}
Array<Asset*> Content::GetAssets()
{
Array<Asset*> assets;