A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
KartAction.hh
1#pragma once
2
3#include "game/kart/KartObjectProxy.hh"
4
5namespace Kart {
6
7enum class Action {
8 None = -1,
9 UNK_0 = 0,
10 UNK_1 = 1,
11 UNK_2 = 2,
12 UNK_3 = 3,
13 UNK_4 = 4,
14 UNK_5 = 5,
15 UNK_6 = 6,
16 UNK_7 = 7,
17 UNK_8 = 8,
18 UNK_9 = 9,
19 UNK_12 = 12,
20 UNK_14 = 14,
21 UNK_16 = 16,
22 Max = 18,
23};
24
26public:
27 enum class eFlags {
28 Landing = 0,
29 Rotating = 3,
30 };
32
33 KartAction();
35
36 void init();
37 void calc();
38 void calcVehicleSpeed();
39 bool start(Action action);
40 void startRotation(size_t idx);
41
42 void setHitDepth(const EGG::Vector3f &hitDepth) {
43 m_hitDepth = hitDepth;
44 }
45
46 void setTranslation(const EGG::Vector3f &v) {
47 m_translation = v;
48 }
49
50 [[nodiscard]] const Flags &flags() const {
51 return m_flags;
52 }
53
54private:
56 struct ActionParams {
57 f32 startSpeedMult;
58 f32 calcSpeedMult;
59 s16 priority;
60 };
61
63 f32 initialAngleIncrement;
64 f32 minAngleIncrement;
65 f32 minMultiplier;
66 f32 initialMultiplierDecrement;
67 f32 slowdownThreshold;
68 f32 finalAngle;
69 };
70
71 // The player index sent into StartActionFunc is assumed to be cosmetic
72 typedef void (KartAction::*StartActionFunc)();
73 typedef bool (KartAction::*CalcActionFunc)();
74 typedef void (KartAction::*EndActionFunc)(bool arg);
75
76 void calcSideFromHitDepth();
77 void calcSideFromHitDepthAndTranslation();
78
79 void end();
80
81 bool calcCurrentAction();
82 void calcEndAction(bool endArg);
83 bool calcRotation();
84 void calcUp();
85 void calcLanding();
86 void startLaunch(f32 extVelScalar, f32 extVelKart, f32 extVelBike, f32 numRotations,
87 u32 param6);
88 void activateCrush(u16 timer);
89
90 void applyStartSpeed();
91 void setRotation(size_t idx);
92
93 /* ================================ *
94 * START FUNCTIONS
95 * ================================ */
96
97 void startStub();
98 void startAction1();
99 void startAction2();
100 void startAction3();
101 void startAction5();
102 void startAction9();
103 void startLongPressAction();
104 void startShortPressAction();
105
106 /* ================================ *
107 * CALC FUNCTIONS
108 * ================================ */
109
110 bool calcStub();
111 bool calcAction1();
112 bool calcLaunchAction();
113 bool calcPressAction();
114
115 /* ================================ *
116 * END FUNCTIONS
117 * ================================ */
118
119 void endStub(bool arg);
120 void endAction1(bool arg);
121 void endLaunchAction(bool arg);
122
123 EGG::Vector3f m_side;
124 Action m_currentAction;
125 f32 m_rotationDirection;
126 f32 m_targetRot;
127 EGG::Vector3f m_hitDepth;
128 EGG::Vector3f m_rotAxis;
129 EGG::Vector3f m_translation;
130
131 StartActionFunc m_onStart;
132 CalcActionFunc m_onCalc;
133 EndActionFunc m_onEnd;
134
135 EGG::Quatf m_rotation;
136 const ActionParams *m_actionParams;
137 u32 m_frame;
138 u32 m_crushTimer;
139 Flags m_flags;
140 f32 m_currentAngle;
141 f32 m_angleIncrement;
142 f32 m_multiplier;
143 f32 m_multiplierDecrement;
144 f32 m_finalAngle;
145 const RotationParams *m_rotationParams;
146 EGG::Vector3f m_up;
147 s16 m_priority;
148
149 static constexpr size_t MAX_ACTION = static_cast<size_t>(Action::Max);
150
151 static const std::array<ActionParams, MAX_ACTION> s_actionParams;
152 static const std::array<RotationParams, 5> s_rotationParams;
153
154 static const std::array<StartActionFunc, MAX_ACTION> s_onStart;
155 static const std::array<CalcActionFunc, MAX_ACTION> s_onCalc;
156 static const std::array<EndActionFunc, MAX_ACTION> s_onEnd;
157};
158
159} // namespace Kart
void startRotation(size_t idx)
Initializes rotation parameters.
Definition KartAction.cc:85
bool calcCurrentAction()
Executes a frame of the current action.
bool start(Action action)
Starts an action.
Definition KartAction.cc:49
Base class for most kart-related objects.
Pertains to kart-related functionality.
A quaternion, used to represent 3D rotation.
Definition Quat.hh:12
Wrapper around an integral type with an enum corresponding to its bits.
Definition BitFlag.hh:16
A 3D float vector.
Definition Vector.hh:88
Parameters specific to an action ID.
Definition KartAction.hh:56