diff --git a/SHADE_Engine/src/Assets/SHAssetManager.cpp b/SHADE_Engine/src/Assets/SHAssetManager.cpp index bcae992e..3032ba51 100644 --- a/SHADE_Engine/src/Assets/SHAssetManager.cpp +++ b/SHADE_Engine/src/Assets/SHAssetManager.cpp @@ -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(); } /**************************************************************************** diff --git a/SHADE_Engine/src/Assets/SHAssetManager.h b/SHADE_Engine/src/Assets/SHAssetManager.h index 4c1ded71..9ee7ab92 100644 --- a/SHADE_Engine/src/Assets/SHAssetManager.h +++ b/SHADE_Engine/src/Assets/SHAssetManager.h @@ -76,25 +76,7 @@ namespace SHADE // -------------------------------------------------------------------------/ template - static std::enable_if_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(assetData[id]); - } - } - - SHLOG_ERROR("Asset ID provided does not exist: {}", id); - return nullptr; - } - - return dynamic_cast(assetData[id]); - } + static std::enable_if_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 assetData; }; } + +#include "SHAssetManager.hpp" diff --git a/SHADE_Engine/src/Assets/SHAssetManager.hpp b/SHADE_Engine/src/Assets/SHAssetManager.hpp new file mode 100644 index 00000000..6c420778 --- /dev/null +++ b/SHADE_Engine/src/Assets/SHAssetManager.hpp @@ -0,0 +1,26 @@ + +#include "SHAssetManager.h" + +namespace SHADE +{ + template + std::enable_if_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(assetData[id]); + } + } + + SHLOG_ERROR("Asset ID provided does not exist: {}", id); + return nullptr; + } + + return dynamic_cast(assetData[id]); + } +} diff --git a/SHADE_Engine/src/Resource/SHResourceManager.hpp b/SHADE_Engine/src/Resource/SHResourceManager.hpp index fb0dcc6a..cff4e84b 100644 --- a/SHADE_Engine/src/Resource/SHResourceManager.hpp +++ b/SHADE_Engine/src/Resource/SHResourceManager.hpp @@ -134,7 +134,7 @@ namespace SHADE /* Query Functions */ /*-----------------------------------------------------------------------------------*/ template - static std::optional SHResourceManager::GetAssetID(Handle handle) + std::optional SHResourceManager::GetAssetID(Handle handle) { const Handle GENERIC_HANDLE = Handle(handle); auto [typedHandleMap, typedAssetIdMap] = getAssetHandleMap();