#include "soh/resource/importer/PathFactory.h" #include "soh/resource/type/Path.h" #include "spdlog/spdlog.h" namespace Ship { std::shared_ptr PathFactory::ReadResource(uint32_t version, std::shared_ptr reader) { auto resource = std::make_shared(); std::shared_ptr factory = nullptr; switch (version) { case 0: factory = std::make_shared(); break; } if (factory == nullptr) { SPDLOG_ERROR("Failed to load Path with version {}", version); return nullptr; } factory->ParseFileBinary(reader, resource); return resource; } void Ship::PathFactoryV0::ParseFileBinary(std::shared_ptr reader, std::shared_ptr resource) { std::shared_ptr path = std::static_pointer_cast(resource); ResourceVersionFactory::ParseFileBinary(reader, path); path->numPaths = reader->ReadUInt32(); path->paths.reserve(path->numPaths); for (uint32_t k = 0; k < path->numPaths; k++) { std::vector points; uint32_t pointCount = reader->ReadUInt32(); points.reserve(pointCount); for (uint32_t i = 0; i < pointCount; i++) { Vec3s point; point.x = reader->ReadInt16(); point.y = reader->ReadInt16(); point.z = reader->ReadInt16(); points.push_back(point); } PathData pathDataEntry; pathDataEntry.count = pointCount; path->paths.push_back(points); pathDataEntry.points = path->paths.back().data(); path->pathData.push_back(pathDataEntry); } } } // namespace Ship