A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectDossunTsuibiHolder.hh
1#pragma once
2
3#include "game/field/obj/ObjectCollidable.hh"
4
5#include <array>
6
7namespace Field {
8
9class ObjectDossunTsuibi;
10
13public:
16
17 void init() override;
18 void calc() override;
19
21 void calcModel() override {}
22
24 [[nodiscard]] u32 loadFlags() const override {
25 return 1;
26 }
27
29 void loadGraphics() override {}
30
32 void createCollision() override {}
33
34 void startStill() {
35 m_state = State::Backward;
36 m_railInterpolator->setCurrVel(m_vel);
37 }
38
39private:
41 void calcStill() {
42 if (--m_stillTimer == 0) {
43 m_state = State::Forward;
44 m_movingSideways = false;
45 }
46 }
47
48 void calcForward();
49 void calcStartStomp();
50 void calcStomp();
51 void calcBackwards();
52
54 void calcStillRotating() {
55 updatePos(EGG::Vector3f(m_pos.x, m_pos.y, m_pos.z - m_resetZVel));
56 }
57
58 void calcRot();
59 void calcForwardRail();
60 void calcForwardOscillation();
61
62 void updatePos(const EGG::Vector3f &pos);
63 void updateRot(f32 rot);
64
65 enum class State {
66 Still = 0,
67 Forward = 1,
68 StartStomp = 2,
69 Stomping = 3,
70 Backward = 4,
71 SillRotating = 5,
72 };
73
74 std::array<ObjectDossunTsuibi *, 2> m_dossuns;
75 State m_state;
76 EGG::Vector3f m_initPos;
77 u32 m_stillTimer;
78 bool m_movingForward;
79 u32 m_forwardTimer;
82 u32 m_sidewaysPhase;
83 bool m_facingBackwards;
86 f32 m_vel;
87 f32 m_initRotY;
91
92 // These members are not in the base game but we add them to prevent dereferencing m_mapObj.
93 const f32 m_forwardVel;
94 const u32 m_stillDuration;
95
97 static constexpr u32 HOME_RESET_FRAMES = 36;
98 static constexpr f32 DOSSUN_POS_OFFSET = 500.0f;
99};
100
101} // namespace Field
The manager class for the pair of Thwomps in the long hallway on rBC.
f32 m_lastStompZ
Z-position of the last stomp.
@ StartStomp
One frame in which the holder activates the Thwomp stomp.
@ Forward
Moving forward down the hallway.
@ Backward
Moving backwards up the hallway.
@ SillRotating
Returned back to home, but rotating to face hallway.
const u32 m_stillDuration
How long Thwomps remain at their home for.
static constexpr u32 HOME_RESET_FRAMES
How long Thwomps take to reset after returning to home.
u32 m_flipSideways
Inverts which direction the thwomps move along the z-axis.
f32 m_resetZVel
Speed required to move from m_lastStompZ to the home's Z in 36 frames.
bool m_movingSideways
Whether the Thwomps should move along the z-axis.
f32 m_resetAngVel
Rotational speed of Thwomps after returning home.
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88