2024-01-05 10:15:41 -06:00
|
|
|
#include "2s2h/resource/importer/PathFactory.h"
|
|
|
|
|
#include "2s2h/resource/type/Path.h"
|
|
|
|
|
#include "spdlog/spdlog.h"
|
|
|
|
|
|
2024-03-26 21:26:31 -04:00
|
|
|
namespace SOH {
|
2024-05-03 15:57:40 -04:00
|
|
|
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryPathMMV0::ReadResource(std::shared_ptr<Ship::File> file) {
|
2024-03-26 21:26:31 -04:00
|
|
|
if (!FileHasValidFormatAndReader(file)) {
|
2024-01-05 10:15:41 -06:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-26 21:26:31 -04:00
|
|
|
auto path = std::make_shared<PathMM>(file->InitData);
|
2024-05-03 15:57:40 -04:00
|
|
|
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
|
2024-01-05 10:15:41 -06:00
|
|
|
|
|
|
|
|
path->numPaths = reader->ReadUInt32();
|
|
|
|
|
path->paths.reserve(path->numPaths);
|
|
|
|
|
for (uint32_t k = 0; k < path->numPaths; k++) {
|
|
|
|
|
std::vector<Vec3s> points;
|
|
|
|
|
uint32_t pointCount = reader->ReadUInt32();
|
|
|
|
|
|
|
|
|
|
uint8_t additionalPathIndex = reader->ReadUByte();
|
|
|
|
|
int16_t customValue = reader->ReadInt16();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PathDataMM pathDataEntry;
|
|
|
|
|
pathDataEntry.count = pointCount;
|
|
|
|
|
pathDataEntry.additionalPathIndex = additionalPathIndex;
|
|
|
|
|
pathDataEntry.customValue = customValue;
|
|
|
|
|
|
|
|
|
|
path->paths.push_back(points);
|
|
|
|
|
pathDataEntry.points = path->paths.back().data();
|
|
|
|
|
|
|
|
|
|
path->pathData.push_back(pathDataEntry);
|
|
|
|
|
}
|
2024-03-26 21:26:31 -04:00
|
|
|
|
|
|
|
|
return path;
|
2024-01-05 10:15:41 -06:00
|
|
|
}
|
2024-03-26 21:26:31 -04:00
|
|
|
} // namespace SOH
|