A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectDossun.hh
1#pragma once
2
3#include "game/field/obj/ObjectCollidable.hh"
4
5namespace Kinoko::Field {
6class ObjectDossunTsuibiHolder;
7
14
15public:
17 ~ObjectDossun() override;
18
19 void init() override;
20
21 [[nodiscard]] u32 loadFlags() const override {
22 return 1;
23 }
24
25 void calcCollisionTransform() override;
26 Kart::Reaction onCollision(Kart::KartObject *kartObj, Kart::Reaction reactionOnKart,
27 Kart::Reaction reactionOnObj, EGG::Vector3f &hitDepth) override;
28
29 void initState();
30 void calcStomp();
31
33 virtual void startStill() {
34 m_anmState = AnmState::Still;
35 m_shakePhase = 0;
36 m_vel = 0.0f;
37 m_flags.setBit(eFlags::Rotation);
38 m_rot.y = m_currRot;
39 }
40
42 void startGrounded() {
43 m_anmState = AnmState::Grounded;
44 m_groundedTimer = GROUND_DURATION;
45 }
46
47protected:
49 enum class AnmState {
50 Still = 0,
51 BeforeFall = 1,
52 Falling = 2,
53 Grounded = 3,
54 Rising = 4,
55 };
56
57 enum class StompState {
58 Inactive = 0,
59 Active = 1,
60 };
61
62 StompState m_stompState;
63 AnmState m_anmState;
68 f32 m_vel;
69 f32 m_initialPosY;
71 s32 m_cycleTimer;
72 f32 m_currRot;
73 bool m_touchingGround;
74
76 static constexpr u32 BEFORE_FALL_DURATION = 10;
77
78private:
79 void calcBeforeFall();
80 void calcFalling();
81
83 void calcGrounded() {
84 if (--m_groundedTimer == 0) {
85 m_anmState = AnmState::Rising;
86 }
87 }
88
90 void calcRising() {
91 m_pos.y = std::min(RISING_VEL + m_pos.y, m_initialPosY);
92 m_flags.setBit(eFlags::Position);
93 }
94
95 void checkFloorCollision();
96
97 static constexpr u32 GROUND_DURATION = 60;
98 static constexpr u32 STOMP_ACCEL = 17.0f;
99 static constexpr f32 STOMP_RADIUS = 20.0f;
100 static constexpr EGG::Vector3f STOMP_POS_OFFSET = EGG::Vector3f(0.0f, STOMP_RADIUS, 0.0f);
101 static constexpr f32 RISING_VEL = 10.0f;
102};
103
104} // namespace Kinoko::Field
The manager class for the pair of Thwomps in the long hallway on rBC.
Base class for the various different Thwomp types in the game.
u32 m_fullDuration
Framecount of an entire animation loop.
AnmState
Represents the current movement state of the Thwomp in terms of its stomp.
@ BeforeFall
The quick upwards motion before slamming down.
s32 m_shakePhase
Causes the Thwomp's position to shake at the end of the "still" state.
s32 m_stillTimer
Number of frames the Thwomp will remain stationary (or shakes)
s32 m_groundedTimer
Number of frames the Thwomp remains on the ground.
f32 m_vel
Vector3f in the base game, but only the y-component is used.
s32 m_beforeFallTimer
Number of frames until the Thwomp will stomp down.
static constexpr u32 BEFORE_FALL_DURATION
The total number of frames the thwomp rises before crashing down.
The highest level abstraction for a kart.
Definition KartObject.hh:11
Pertains to collision.
constexpr TBitFlag< T, E > & setBit(Es... es)
Sets the corresponding bits for the provided enum values.
Definition BitFlag.hh:64
A 3D float vector.
Definition Vector.hh:107