Removed line that loaded all assets
Separated template function in asset manager into hpp file Fixed bug in checking map contains
This commit is contained in:
parent
304071cb0a
commit
a83d1f8f04
|
@ -56,18 +56,15 @@ namespace SHADE
|
|||
****************************************************************************/
|
||||
void SHAssetManager::Unload() noexcept
|
||||
{
|
||||
for (auto const& asset : assetCollection)
|
||||
{
|
||||
SHAssetMetaHandler::WriteMetaData(asset);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SHAssetManager::Unload(AssetID assetId) noexcept
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
void SHAssetManager::Unload(AssetID assetId) noexcept
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
AssetPath SHAssetManager::GenerateLocalPath(AssetPath path) noexcept
|
||||
AssetPath SHAssetManager::GenerateLocalPath(AssetPath path) noexcept
|
||||
{
|
||||
if (!IsRecognised(path.extension().string().c_str()))
|
||||
{
|
||||
|
@ -256,7 +253,7 @@ namespace SHADE
|
|||
{
|
||||
InitLoaders();
|
||||
BuildAssetCollection();
|
||||
LoadAllData();
|
||||
//LoadAllData();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -76,25 +76,7 @@ namespace SHADE
|
|||
// -------------------------------------------------------------------------/
|
||||
|
||||
template<typename T>
|
||||
static std::enable_if_t<std::is_base_of_v<SHAssetData, T>, T const * const> GetData(AssetID id) noexcept
|
||||
{
|
||||
if (assetData.contains(id))
|
||||
{
|
||||
for (auto const& asset : assetCollection)
|
||||
{
|
||||
if (asset.id == id)
|
||||
{
|
||||
assetData.emplace(id, LoadData(asset));
|
||||
return dynamic_cast<T const * const>(assetData[id]);
|
||||
}
|
||||
}
|
||||
|
||||
SHLOG_ERROR("Asset ID provided does not exist: {}", id);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return dynamic_cast<T const * const>(assetData[id]);
|
||||
}
|
||||
static std::enable_if_t<std::is_base_of_v<SHAssetData, T>, T const* const> GetData(AssetID id) noexcept;
|
||||
private:
|
||||
/****************************************************************************
|
||||
* \brief Load resource data into memory
|
||||
|
@ -121,3 +103,5 @@ namespace SHADE
|
|||
static std::unordered_map<AssetID, SHAssetData * const> assetData;
|
||||
};
|
||||
}
|
||||
|
||||
#include "SHAssetManager.hpp"
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
#include "SHAssetManager.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
template<typename T>
|
||||
std::enable_if_t<std::is_base_of_v<SHAssetData, T>, T const* const> SHAssetManager::GetData(AssetID id) noexcept
|
||||
{
|
||||
if (!assetData.contains(id))
|
||||
{
|
||||
for (auto const& asset : assetCollection)
|
||||
{
|
||||
if (asset.id == id)
|
||||
{
|
||||
assetData.emplace(id, LoadData(asset));
|
||||
return dynamic_cast<T const* const>(assetData[id]);
|
||||
}
|
||||
}
|
||||
|
||||
SHLOG_ERROR("Asset ID provided does not exist: {}", id);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return dynamic_cast<T const* const>(assetData[id]);
|
||||
}
|
||||
}
|
|
@ -134,7 +134,7 @@ namespace SHADE
|
|||
/* Query Functions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
template<typename T>
|
||||
static std::optional<AssetID> SHResourceManager::GetAssetID(Handle<T> handle)
|
||||
std::optional<AssetID> SHResourceManager::GetAssetID(Handle<T> handle)
|
||||
{
|
||||
const Handle GENERIC_HANDLE = Handle(handle);
|
||||
auto [typedHandleMap, typedAssetIdMap] = getAssetHandleMap<T>();
|
||||
|
|
Loading…
Reference in New Issue