Files
Shiip-of-Hakinian-Espanol/soh/soh/resource/importer/scenecommand/SetPathwaysFactory.cpp
Kenix3 4980ae8dcc Lus updates (#2822)
* Changes for LUS renames in ResourceManager and Archive.

* Moves WriteSaveFile and ReadSaveFile to SaveManager.

* Removes ImGui namespace.

* Bump LUS

* Update soh/soh/GameMenuBar.cpp

* Bump LUS

---------

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
2023-05-03 20:46:26 -04:00

45 lines
1.7 KiB
C++

#include "soh/resource/importer/scenecommand/SetPathwaysFactory.h"
#include "soh/resource/type/scenecommand/SetPathways.h"
#include "spdlog/spdlog.h"
#include <libultraship/bridge.h>
namespace Ship {
std::shared_ptr<Resource> SetPathwaysFactory::ReadResource(std::shared_ptr<ResourceManager> resourceMgr,
std::shared_ptr<ResourceInitData> initData,
std::shared_ptr<BinaryReader> reader) {
auto resource = std::make_shared<SetPathways>(resourceMgr, initData);
std::shared_ptr<ResourceVersionFactory> factory = nullptr;
switch (resource->InitData->ResourceVersion) {
case 0:
factory = std::make_shared<SetPathwaysFactoryV0>();
break;
}
if (factory == nullptr) {
SPDLOG_ERROR("Failed to load SetPathways with version {}", resource->InitData->ResourceVersion);
return nullptr;
}
factory->ParseFileBinary(reader, resource);
return resource;
}
void Ship::SetPathwaysFactoryV0::ParseFileBinary(std::shared_ptr<BinaryReader> reader,
std::shared_ptr<Resource> resource) {
std::shared_ptr<SetPathways> setPathways = std::static_pointer_cast<SetPathways>(resource);
ResourceVersionFactory::ParseFileBinary(reader, setPathways);
ReadCommandId(setPathways, reader);
setPathways->numPaths = reader->ReadUInt32();
setPathways->paths.reserve(setPathways->numPaths);
for (uint32_t i = 0; i < setPathways->numPaths; i++) {
std::string pathFileName = reader->ReadString();
setPathways->paths.push_back(std::static_pointer_cast<Path>(LoadResource(pathFileName.c_str(), true)));
}
}
} // namespace Ship