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 {
7
12class ObjectDossun : public ObjectCollidable {
13 friend ObjectDossunTsuibiHolder;
14
15public:
16 ObjectDossun(const System::MapdataGeoObj &params);
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 setRot(EGG::Vector3f(rot().x, m_currRot, rot().z));
38 }
39
41 void startGrounded() {
42 m_anmState = AnmState::Grounded;
43 m_groundedTimer = GROUND_DURATION;
44 }
45
46protected:
48 enum class AnmState {
49 Still = 0,
51 Falling = 2,
53 Rising = 4,
54 };
55
56 enum class StompState {
57 Inactive = 0,
58 Active = 1,
59 };
60
61 StompState m_stompState;
62 AnmState m_anmState;
67 f32 m_vel;
68 f32 m_initialPosY;
70 s32 m_cycleTimer;
71 f32 m_currRot;
72 bool m_touchingGround;
73
75 static constexpr u32 BEFORE_FALL_DURATION = 10;
76
77private:
78 void calcBeforeFall();
79
81 void calcFalling() {
82 m_vel -= STOMP_ACCEL;
83 setPos(EGG::Vector3f(pos().x, m_vel + pos().y, pos().z));
84 checkFloorCollision();
85 }
86
88 void calcGrounded() {
89 if (--m_groundedTimer == 0) {
90 m_anmState = AnmState::Rising;
91 }
92 }
93
95 void calcRising() {
96 f32 posY = std::min(RISING_VEL + pos().y, m_initialPosY);
97 setPos(EGG::Vector3f(pos().x, posY, pos().z));
98 }
99
100 void checkFloorCollision();
101
102 static constexpr u32 GROUND_DURATION = 60;
103 static constexpr u32 STOMP_ACCEL = 17.0f;
104 static constexpr f32 STOMP_RADIUS = 20.0f;
105 static constexpr EGG::Vector3f STOMP_POS_OFFSET = EGG::Vector3f(0.0f, STOMP_RADIUS, 0.0f);
106 static constexpr f32 RISING_VEL = 10.0f;
107};
108
109} // namespace Kinoko::Field
The manager class for the pair of Thwomps in the long hallway on rBC.
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.
A 3D float vector.
Definition Vector.hh:107