#pragma once #include "AssetPool.h" #include "Zone/ZoneTypes.h" #include #include #include #include struct LinkedAssetPool { AssetPool* m_asset_pool; zone_priority_t m_priority; }; struct GameAssetPoolEntry { XAssetInfoGeneric* m_asset; LinkedAssetPool* m_asset_pool; bool m_duplicate; }; class GlobalAssetPool { public: void LinkAssetPool(AssetPool* assetPool, zone_priority_t priority); void LinkAsset(const AssetPool* assetPool, const std::string& normalizedAssetName, XAssetInfoGeneric* asset); void UnlinkAssetPool(const AssetPool* assetPool); XAssetInfoGeneric* GetAsset(const std::string& name); private: void SortLinkedAssetPools(); bool ReplaceAssetPoolEntry(GameAssetPoolEntry& assetEntry) const; void LinkAsset(LinkedAssetPool* link, const std::string& normalizedAssetName, XAssetInfoGeneric* asset); std::vector> m_linked_asset_pools; std::unordered_map m_assets; }; class GameGlobalAssetPools { public: explicit GameGlobalAssetPools(GameId gameId); void LinkAssetPool(asset_type_t assetType, AssetPool* assetPool, zone_priority_t priority) const; void LinkAsset(asset_type_t assetType, const AssetPool* assetPool, const std::string& normalizedAssetName, XAssetInfoGeneric* asset) const; void UnlinkAssetPool(asset_type_t assetType, const AssetPool* assetPool) const; [[nodiscard]] XAssetInfoGeneric* GetAsset(asset_type_t assetType, const std::string& name) const; template [[nodiscard]] XAssetInfo* GetAsset(const std::string& name) const { return reinterpret_cast*>(GetAsset(Asset_t::EnumEntry, name)); } static GameGlobalAssetPools* GetGlobalPoolsForGame(GameId gameId); private: std::vector> m_global_asset_pools; };