1#include "RailManager.hh"
3#include "game/system/CourseMap.hh"
4#include "game/system/map/MapdataGeoObj.hh"
9RailManager *RailManager::CreateInstance() {
11 s_instance =
new RailManager;
12 s_instance->createPaths();
17void RailManager::DestroyInstance() {
19 auto *instance = s_instance;
25RailManager::RailManager() =
default;
28RailManager::~RailManager() =
default;
31void RailManager::createPaths() {
32 auto *courseMap = System::CourseMap::Instance();
33 m_pointCount = courseMap->getPointInfoCount();
34 m_extraInterplatorCount = 8;
35 u16 geoCount = courseMap->getGeoObjCount();
36 m_rails.reserve(m_pointCount + m_extraInterplatorCount);
37 m_interpolatorTotal = m_pointCount;
40 m_cameraPointCount = m_pointCount * 1;
41 m_interpolatorTotal = m_pointCount * 1 + m_extraInterplatorCount;
45 m_interpolators = std::span<RailInterpolator *>(
new RailInterpolator *[m_interpolatorTotal],
48 for (
u16 i = 0; i < m_pointCount; ++i) {
49 bool isObjectRoute =
false;
50 auto *pointInfo = courseMap->getPointInfo(i);
51 bool isSpline = pointInfo->setting(0);
53 for (
u16 j = 0; j < geoCount; ++j) {
54 auto *geoObj = courseMap->getGeoObj(j);
56 if (geoObj->pathId() != i) {
61 m_rails.push_back(
new RailSpline(i, pointInfo));
63 m_rails.push_back(
new RailLine(i, pointInfo));
75 m_rails.push_back(
new RailSpline(i, pointInfo));
77 for (
u16 j = 0; j < m_cameraCount; ++j) {
78 m_interpolators[j + i * m_cameraCount] =
new RailSmoothInterpolator(0.0f, i);
81 m_rails.push_back(
new RailLine(i, pointInfo));
83 for (
u16 j = 0; j < m_cameraCount; ++j) {
84 m_interpolators[j + i * m_cameraCount] =
new RailLinearInterpolator(0.0f, i);
90RailManager *RailManager::s_instance =
nullptr;