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

chore: add force loading of assets

This commit is contained in:
Jan
2025-01-21 23:11:37 +01:00
parent b4194eff28
commit 990bfe27df
4 changed files with 90 additions and 7 deletions

View File

@@ -65,12 +65,31 @@ public:
IndirectAssetReference LoadIndirectAssetReferenceGeneric(asset_type_t assetType, const std::string& assetName);
/**
* \brief Loads an asset dependency like \c LoadDependency but guarantees that the returned asset is not a reference.
* If normally a reference would be created, the actual asset is loaded but a reference is added to the zone.
* \tparam AssetType The type of the asset
* \param assetName The name of the asset
* \return XAssetInfo of the asset that is guaranteed to not be a reference or \c nullptr
*/
template<typename AssetType> XAssetInfo<typename AssetType::Type>* ForceLoadDependency(const std::string& assetName)
{
static_assert(std::is_base_of_v<IAssetBase, AssetType>);
return static_cast<XAssetInfo<typename AssetType::Type>*>(ForceLoadDependencyGeneric(AssetType::EnumEntry, assetName));
}
XAssetInfoGeneric* ForceLoadDependencyGeneric(asset_type_t assetType, const std::string& assetName);
private:
[[nodiscard]] XAssetInfoGeneric* LoadDefaultAssetDependency(asset_type_t assetType, const std::string& assetName);
Zone& m_zone;
std::unique_ptr<ZoneAssetPools> m_forced_asset_pools;
const AssetCreatorCollection* m_creators;
const IgnoredAssetLookup* m_ignored_asset_lookup;
unsigned m_forced_load_depth;
};
#include "AssetCreatorCollection.h"