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 = 1,
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 startAction5();
100 void startAction9();
101 void startLongPressAction();
102 void startShortPressAction();
103
104 /* ================================ *
105 * CALC FUNCTIONS
106 * ================================ */
107
108 bool calcStub();
109 bool calcAction1();
110 bool calcAction5();
111 bool calcPressAction();
112
113 /* ================================ *
114 * END FUNCTIONS
115 * ================================ */
116
117 void endStub(bool arg);
118 void endAction1(bool arg);
119 void endAction5(bool arg);
120
121 EGG::Vector3f m_side;
122 Action m_currentAction;
123 f32 m_rotationDirection;
124 f32 m_targetRot;
125 EGG::Vector3f m_hitDepth;
126 EGG::Vector3f m_rotAxis;
127 EGG::Vector3f m_translation;
128
129 StartActionFunc m_onStart;
130 CalcActionFunc m_onCalc;
131 EndActionFunc m_onEnd;
132
133 EGG::Quatf m_rotation;
134 const ActionParams *m_actionParams;
135 u32 m_frame;
136 u32 m_crushTimer;
137 Flags m_flags;
138 f32 m_currentAngle;
139 f32 m_angleIncrement;
140 f32 m_multiplier;
141 f32 m_multiplierDecrement;
142 f32 m_finalAngle;
143 const RotationParams *m_rotationParams;
144 EGG::Vector3f m_up;
145 s16 m_priority;
146
147 static constexpr size_t MAX_ACTION = static_cast<size_t>(Action::Max);
148
149 static const std::array<ActionParams, MAX_ACTION> s_actionParams;
150 static const std::array<RotationParams, 5> s_rotationParams;
151
152 static const std::array<StartActionFunc, MAX_ACTION> s_onStart;
153 static const std::array<CalcActionFunc, MAX_ACTION> s_onCalc;
154 static const std::array<EndActionFunc, MAX_ACTION> s_onEnd;
155};
156
157} // 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:87
Parameters specific to an action ID.
Definition KartAction.hh:56