mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-11-23 21:22:07 +00:00
Initial commit of BSP compilation
This commit is contained in:
57
src/ObjLoading/Game/T6/CustomMap/LoaderCustomMapT6.cpp
Normal file
57
src/ObjLoading/Game/T6/CustomMap/LoaderCustomMapT6.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "LoaderCustomMapT6.h"
|
||||
#include "ProjectCreator.h"
|
||||
#include "CustomMapLinker.h"
|
||||
|
||||
#include "Game/T6/T6.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace T6;
|
||||
|
||||
namespace
|
||||
{
|
||||
class CustomMapLoader final : public AssetCreator<AssetCustomMap>
|
||||
{
|
||||
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
|
||||
{
|
||||
auto mapFile = m_search_path.Open("custom_map/map.obj");
|
||||
if (!mapFile.IsOpen())
|
||||
return AssetCreationResult::NoAction();
|
||||
|
||||
// create map info from the obj file
|
||||
customMapInfo* mapInfo = CustomMapInfo::createCustomMapInfo(m_zone.m_name, m_search_path);
|
||||
if (mapInfo == NULL)
|
||||
return AssetCreationResult::Failure();
|
||||
|
||||
// linker will add all the assets needed
|
||||
CustomMapLinker* linker = new CustomMapLinker(m_memory, m_search_path, m_zone);
|
||||
bool result = linker->linkCustomMap(mapInfo);
|
||||
|
||||
if (result)
|
||||
return AssetCreationResult::NoAction();
|
||||
else
|
||||
return AssetCreationResult::Failure();
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryManager& m_memory;
|
||||
ISearchPath& m_search_path;
|
||||
Zone& m_zone;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace T6
|
||||
{
|
||||
std::unique_ptr<AssetCreator<AssetCustomMap>> CreateCustomMapLoader(MemoryManager& memory, ISearchPath& searchPath, Zone& zone)
|
||||
{
|
||||
return std::make_unique<CustomMapLoader>(memory, searchPath, zone);
|
||||
}
|
||||
} // namespace T6
|
||||
Reference in New Issue
Block a user