A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
KartState.hh
1#pragma once
2
3#include "game/kart/KartObjectProxy.hh"
4#include "game/kart/Status.hh"
5
6namespace Kart {
7
14public:
15 KartState();
16
17 void init();
18 void reset();
19
20 void calcInput();
21 void calc();
22 void resetFlags();
23 void calcCollisions();
24 void calcStartBoost();
26 void handleStartBoost(size_t idx);
27 void resetEjection();
28
30 void setCannonPointId(u16 val) {
31 m_cannonPointId = val;
32 }
33
34 void setBoostRampType(s32 val) {
35 m_boostRampType = val;
36 }
37
38 void setJumpPadVariant(s32 val) {
39 m_jumpPadVariant = val;
40 }
41
42 void setHalfPipeInvisibilityTimer(s16 val) {
43 m_halfPipeInvisibilityTimer = val;
44 }
45
46 void setTrickableTimer(s16 val) {
47 m_trickableTimer = val;
48 }
50
52 [[nodiscard]] bool isDrifting() const {
53 return m_status.onBit(eStatus::DriftManual, eStatus::DriftAuto);
54 }
55
56 [[nodiscard]] u16 cannonPointId() const {
57 return m_cannonPointId;
58 }
59
60 [[nodiscard]] s32 boostRampType() const {
61 return m_boostRampType;
62 }
63
64 [[nodiscard]] s32 jumpPadVariant() const {
65 return m_jumpPadVariant;
66 }
67
68 [[nodiscard]] f32 stickX() const {
69 return m_stickX;
70 }
71
72 [[nodiscard]] f32 stickY() const {
73 return m_stickY;
74 }
75
76 [[nodiscard]] u32 airtime() const {
77 return m_airtime;
78 }
79
80 [[nodiscard]] const EGG::Vector3f &top() const {
81 return m_top;
82 }
83
84 [[nodiscard]] const EGG::Vector3f &softWallSpeed() const {
85 return m_softWallSpeed;
86 }
87
88 [[nodiscard]] f32 startBoostCharge() const {
89 return m_startBoostCharge;
90 }
91
92 [[nodiscard]] s16 wallBonkTimer() const {
93 return m_wallBonkTimer;
94 }
95
96 [[nodiscard]] s16 trickableTimer() const {
97 return m_trickableTimer;
98 }
99
100 [[nodiscard]] Status &status() {
101 return m_status;
102 }
103
104 [[nodiscard]] const Status &status() const {
105 return m_status;
106 }
107
109
110private:
111 Status m_status;
112 u32 m_airtime;
113 EGG::Vector3f m_top;
114 EGG::Vector3f m_softWallSpeed;
115 s32 m_hwgTimer;
116 u16 m_cannonPointId;
117 s32 m_boostRampType;
118 s32 m_jumpPadVariant;
119 s16 m_halfPipeInvisibilityTimer;
125 s16 m_trickableTimer;
126};
127
128} // namespace Kart
constexpr bool onBit(Es... es) const
Checks if any of the corresponding bits for the provided enum values are on.
Definition BitFlag.hh:379
Base class for most kart-related objects.
Houses various flags and other variables to preserve the kart's state.
Definition KartState.hh:13
size_t m_startBoostIdx
Used to map m_startBoostCharge to a start boost duration.
Definition KartState.hh:123
void calcStartBoost()
STAGE 1 - Each frame, calculates the start boost charge.
Definition KartState.cc:352
s16 m_wallBonkTimer
2f counter that stunts your speed after hitting a wall.
Definition KartState.hh:124
void calcCollisions()
Each frame, checks for collision and saves relevant bit flags.
Definition KartState.cc:143
void calcHandleStartBoost()
On countdown end, calculates and applies our start boost charge.
Definition KartState.cc:370
f32 m_stickY
One of 15 discrete stick values from [-1.0, 1.0].
Definition KartState.hh:121
void handleStartBoost(size_t idx)
Applies the relevant start boost duration.
Definition KartState.cc:401
void calc()
Every frame, resets the input state and saves collision-related bit flags.
Definition KartState.cc:115
f32 m_stickX
One of 15 discrete stick values from [-1.0, 1.0].
Definition KartState.hh:120
f32 m_startBoostCharge
0-1 representation of start boost charge. Burnout if >0.95f.
Definition KartState.hh:122
void calcInput()
Each frame, read input and save related bit flags. Also handles start boosts.
Definition KartState.cc:66
void resetEjection()
Resets certain bitfields pertaining to ejections (reject road, half pipe zippers, etc....
Definition KartState.cc:411
Pertains to kart-related functionality.
@ DriftManual
Currently in a drift w/ manual.
A 3D float vector.
Definition Vector.hh:88