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 Kinoko {
8
9namespace Host {
10
11class Context;
12
13} // namespace Host
14
15namespace System {
16
24 friend class Host::Context;
25
26public:
27 struct Player {
28 public:
29 enum class Type {
30 Local = 0, // Inputs managed by ML algorithm
31 Ghost = 3, // Inputs managed by ghost
32 None = 5,
33 };
34
35 Character character;
36 Vehicle vehicle;
37 Type type;
38 bool driftIsAuto;
39 };
40
41 struct Scenario {
42 public:
43 enum class GameMode {
44 Time_Trial = 2,
45 Ghost_Race = 5,
46 };
47
48 void init();
49
50 std::array<Player, 12> players;
51 u8 playerCount;
52 Course course;
53 };
54
55 typedef std::function<void(RaceConfig *, void *)> InitCallback;
56
57 void init();
58 void initRace();
59 void initControllers();
60 void initGhost();
61
62 [[nodiscard]] const Scenario &raceScenario() const {
63 return m_raceScenario;
64 }
65
66 [[nodiscard]] Scenario &raceScenario() {
67 return m_raceScenario;
68 }
69
70 void setGhost(const u8 *rkg) {
71 m_ghost = rkg;
72 }
73
74 static void RegisterInitCallback(const InitCallback &callback, void *arg) {
75 s_onInitCallback = callback;
77 }
78
79 static RaceConfig *CreateInstance();
80 static void DestroyInstance();
81
82 [[nodiscard]] static RaceConfig *Instance() {
83 return s_instance;
84 }
85
86private:
87 RaceConfig();
88 ~RaceConfig() override;
89
90 Scenario m_raceScenario;
91 RawGhostFile m_ghost;
92
93 static RaceConfig *s_instance;
94 static InitCallback s_onInitCallback;
95 static void *s_onInitCallbackArg;
96};
97
98} // namespace System
99
100} // namespace Kinoko
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:71
Initializes the player with parameters specified in the provided ghost file.
Definition RaceConfig.hh:23
static void * s_onInitCallbackArg
The argument sent into the callback. This is expected to be reinterpret_casted.
Definition RaceConfig.hh:95
void initGhost()
Initializes the ghost.
Definition RaceConfig.cc:47
void initControllers()
Initializes the controllers.
Definition RaceConfig.cc:30
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:94