#include "Game/T6/Maps/CustomMaps.h" #include "LoaderCustomMapT6.h" #include "BSPCreator.h" #include "CustomMapLinker.h" #include "Game/T6/T6.h" #include using namespace T6; namespace { class CustomMapLoader final : public AssetCreator { public: CustomMapLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) : m_memory(memory), m_search_path(searchPath), m_zone(zone) { } AssetCreationResult CreateAsset(const std::string& assetName, AssetCreationContext& context) override { // custom maps must have a map_gfx file auto mapGfxFile = m_search_path.Open("custom_map/map_gfx.fbx"); if (!mapGfxFile.IsOpen()) return AssetCreationResult::NoAction(); CustomMapBSP* mapBSP = BSPCreator::createCustomMapBSP(m_zone.m_name, m_search_path); if (mapBSP == NULL) return AssetCreationResult::Failure(); CustomMapLinker* linker = new CustomMapLinker(m_memory, m_search_path, m_zone, context); bool result = linker->linkCustomMap(mapBSP); if (result) { auto gfxWorldAsset = context.LoadDependency(mapBSP->bspName); _ASSERT(gfxWorldAsset != NULL); return AssetCreationResult::Success(gfxWorldAsset); } else return AssetCreationResult::Failure(); } private: MemoryManager& m_memory; ISearchPath& m_search_path; Zone& m_zone; }; } // namespace namespace custom_map { std::unique_ptr> CreateLoaderT6(MemoryManager& memory, ISearchPath& searchPath, Zone& zone) { return std::make_unique(memory, searchPath, zone); } } // namespace custom_map