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