A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
RaceScene.cc
1#include "RaceScene.hh"
2
3#include "game/field/BoxColManager.hh"
4#include "game/field/CollisionDirector.hh"
5#include "game/field/ObjectDirector.hh"
6#include "game/field/RailManager.hh"
7#include "game/item/ItemDirector.hh"
8#include "game/kart/KartObjectManager.hh"
9#include "game/system/CourseMap.hh"
10#include "game/system/KPadDirector.hh"
11#include "game/system/RaceConfig.hh"
12#include "game/system/RaceManager.hh"
13#include "game/system/ResourceManager.hh"
14
15#include <ScopeLock.hh>
16
17namespace Scene {
18
20RaceScene::RaceScene() {
21 m_heap->setName("RaceSceneHeap");
22}
23
25RaceScene::~RaceScene() = default;
26
28void RaceScene::createEngines() {
29 {
30 ScopeLock<GroupID> lock(GroupID::Course);
31 System::CourseMap::CreateInstance()->init();
32 }
33
34 {
35 ScopeLock<GroupID> lock(GroupID::Race);
36 System::RaceManager::CreateInstance();
37 }
38
39 {
40 ScopeLock<GroupID> lock(GroupID::Object);
41 Field::BoxColManager::CreateInstance();
42 }
43
44 {
45 ScopeLock<GroupID> lock(GroupID::Kart);
46 Kart::KartObjectManager::CreateInstance();
47 }
48
49 {
50 ScopeLock<GroupID> lock(GroupID::Course);
51 Field::CollisionDirector::CreateInstance();
52 }
53
54 {
55 ScopeLock<GroupID> lock(GroupID::Item);
56 Item::ItemDirector::CreateInstance();
57 }
58
59 {
60 ScopeLock<GroupID> lock(GroupID::Object);
61 Field::RailManager::CreateInstance();
62 Field::ObjectDirector::CreateInstance();
63 }
64}
65
67void RaceScene::initEngines() {
68 {
69 ScopeLock<GroupID> lock(GroupID::Kart);
70 Kart::KartObjectManager::Instance()->init();
71 }
72
73 {
74 ScopeLock<GroupID> lock(GroupID::Race);
75 System::RaceManager::Instance()->init();
76 }
77
78 {
79 ScopeLock<GroupID> lock(GroupID::Item);
80 Item::ItemDirector::Instance()->init();
81 }
82
83 {
84 ScopeLock<GroupID> lock(GroupID::Object);
85 Field::ObjectDirector::Instance()->init();
86 }
87
88 m_heap->disableAllocation();
89}
90
95 auto *raceMgr = System::RaceManager::Instance();
96 raceMgr->calc();
97 Field::BoxColManager::Instance()->calc();
98 Field::ObjectDirector::Instance()->calc();
99 Kart::KartObjectManager::Instance()->calc();
100 Item::ItemDirector::Instance()->calc();
101 // raceMgr->random1()->nextU32();
102}
103
105void RaceScene::destroyEngines() {
106 System::KPadDirector::Instance()->endGhostProxies();
107 Kart::KartObjectManager::DestroyInstance();
108 Field::ObjectDirector::DestroyInstance();
109 Field::RailManager::DestroyInstance();
110 Field::CollisionDirector::DestroyInstance();
111 Item::ItemDirector::DestroyInstance();
112 Field::BoxColManager::DestroyInstance();
113 System::RaceManager::DestroyInstance();
114 System::CourseMap::DestroyInstance();
115}
116
120 auto *raceCfg = System::RaceConfig::Instance();
121 auto *resMgr = System::ResourceManager::Instance();
122
123 raceCfg->initRace();
124
125 // Normally, the resources are loaded into a specific archive heap
126 // For now, tag them with the resource group ID
127 {
128 ScopeLock<GroupID> lock(GroupID::Resource);
129 auto *commonArc = resMgr->load(0, nullptr);
130 appendResource(commonArc, 0);
131
132 auto *courseArc = resMgr->load(raceCfg->raceScenario().course);
133 appendResource(courseArc, 1);
134 }
135}
136
140 configure();
141}
142
143} // namespace Scene
void calc()
Recalculate the bounds of all active units having PermRecalcAABB or TempRecalcAABB flag,...
void onReinit() override
This is called on race shutdown in order to prep for the next race.
Definition RaceScene.cc:139
void configure() override
Retrieves Common.szs and the course archive.
Definition RaceScene.cc:119
void calcEngines() override
Definition RaceScene.cc:94
Pertains to scene handling.
Definition GameScene.cc:8