A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
RaceConfig.hh
1#pragma once
2
3#include "game/system/GhostFile.hh"
4
5#include <functional>
6
7namespace Host {
8
9class Context;
10
11} // namespace Host
12
13namespace System {
14
22 friend class Host::Context;
23
24public:
25 struct Player {
26 public:
27 enum class Type {
28 Local = 0, // Inputs managed by ML algorithm
29 Ghost = 3, // Inputs managed by ghost
30 None = 5,
31 };
32
33 Character character;
34 Vehicle vehicle;
35 Type type;
36 bool driftIsAuto;
37 };
38
39 struct Scenario {
40 public:
41 enum class GameMode {
42 Time_Trial = 2,
43 Ghost_Race = 5,
44 };
45
46 void init();
47
48 std::array<Player, 12> players;
49 u8 playerCount;
50 Course course;
51 };
52
53 typedef std::function<void(RaceConfig *, void *)> InitCallback;
54
55 void init();
56 void initRace();
57 void initControllers();
58 void initGhost();
59
60 [[nodiscard]] const Scenario &raceScenario() const {
61 return m_raceScenario;
62 }
63
64 [[nodiscard]] Scenario &raceScenario() {
65 return m_raceScenario;
66 }
67
68 void setGhost(const u8 *rkg) {
69 m_ghost = rkg;
70 }
71
72 static void RegisterInitCallback(const InitCallback &callback, void *arg) {
73 s_onInitCallback = callback;
75 }
76
77 static RaceConfig *CreateInstance();
78 static void DestroyInstance();
79
80 [[nodiscard]] static RaceConfig *Instance() {
81 return s_instance;
82 }
83
84private:
85 RaceConfig();
86 ~RaceConfig() override;
87
88 Scenario m_raceScenario;
89 RawGhostFile m_ghost;
90
91 static RaceConfig *s_instance;
92 static InitCallback s_onInitCallback;
93 static void *s_onInitCallbackArg;
94};
95
96} // namespace System
An interface for ensuring certain structures and classes are destroyed with the heap.
Definition Disposer.hh:11
Contexts can be used to restore a previous memory state for the current session.
Definition Context.hh:59
Initializes the player with parameters specified in the provided ghost file.
Definition RaceConfig.hh:21
static void * s_onInitCallbackArg
The argument sent into the callback. This is expected to be reinterpret_casted.
Definition RaceConfig.hh:93
void initGhost()
Initializes the ghost.
Definition RaceConfig.cc:47
static InitCallback s_onInitCallback
Host-agnostic way of initializing RaceConfig. The type of the first player must be set to either Loca...
Definition RaceConfig.hh:92
void initControllers()
Initializes the controllers.
Definition RaceConfig.cc:30
Represents the host application.
Definition HeapCommon.hh:9
High-level handling for generic system operations, such as input reading, race configuration,...
Definition CourseMap.cc:5