2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-05 00:07:25 +00:00

refactor: make LoadDependency and LoadIndirectAssetReference functions work with Asset template types

This commit is contained in:
Jan
2024-04-22 23:36:21 +02:00
parent 0b61fc6e81
commit eb0cec1d81
16 changed files with 106 additions and 90 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include "AssetLoadingContext.h"
#include "Game/IAsset.h"
#include "Pool/XAssetInfo.h"
#include "Utils/ClassUtils.h"
#include "Zone/ZoneTypes.h"
@@ -50,6 +51,21 @@ public:
assetType, assetName, asset, std::move(dependencies), std::move(usedScriptStrings), std::move(indirectAssetReferences)));
}
template<typename AssetType> XAssetInfo<typename AssetType::Type>* LoadDependency(const std::string& assetName)
{
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
return static_cast<XAssetInfo<typename AssetType::Type>*>(LoadDependency(AssetType::EnumEntry, assetName));
}
template<typename AssetType> IndirectAssetReference LoadIndirectAssetReference(const std::string& assetName)
{
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
return LoadIndirectAssetReference(AssetType::EnumEntry, assetName);
}
protected:
virtual XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) = 0;
virtual IndirectAssetReference LoadIndirectAssetReference(asset_type_t assetType, const std::string& assetName) = 0;
};