A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectFlamePoleFoot.hh
1#pragma once
2
3#include "game/field/StateManager.hh"
4#include "game/field/obj/ObjectFlamePole.hh"
5#include "game/field/obj/ObjectKCL.hh"
6
7namespace Field {
8
9class ObjectFlamePole;
10
12class ObjectFlamePoleFoot final : public ObjectKCL, public StateManager {
13public:
15 ~ObjectFlamePoleFoot() override;
16
17 void init() override;
18 void calc() override;
19
21 [[nodiscard]] u32 loadFlags() const override {
22 return 1;
23 }
24
26 [[nodiscard]] f32 getCollisionRadius() const override {
27 return 245.0f * static_cast<f32>(m_mapObj->setting(2));
28 }
29
31 [[nodiscard]] const EGG::Matrix34f &getUpdatedMatrix(u32 /*timeOffset*/) override {
32 calcTransform();
33 m_workMatrix = m_transform;
34 return m_transform;
35 }
36
37 [[nodiscard]] f32 getScaleY(u32 timeOffset) const override;
38 [[nodiscard]] bool checkCollision(f32 radius, const EGG::Vector3f &pos,
39 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info,
40 KCLTypeMask *maskOut, u32 timeOffset) override;
41 [[nodiscard]] bool checkCollisionCached(f32 radius, const EGG::Vector3f &pos,
42 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info,
43 KCLTypeMask *maskOut, u32 timeOffset) override;
44
45private:
47 void enterExpanding() {
48 m_heightOffset = 0.0f;
49 }
50
51 void enterEruptingUp();
52
54 void enterEruptingStay() {
55 m_scaledHeight = m_initScaledHeight;
56 }
57
59 void enterEruptingDown() {
60 m_scaledHeight = m_heightOffset;
61 }
62
64 void enterDormant() {
65 m_pole->setActive(false);
66 m_pole->disableCollision();
67 }
68
70 void enterState5() {}
71
73 void calcExpanding() {}
74
75 void calcEruptingUp();
76 void calcEruptingStay();
77
79 void calcEruptingDown() {
81 m_scaledHeight - m_scaleDelta * static_cast<f32>(m_cycleFrame - m_stateStart[3]);
82 }
83
85 void calcDormant() {}
86
88 void calcState5() {}
89
90 void calcStates();
91
92 EGG::Matrix34f m_workMatrix;
93 ObjectFlamePole *m_pole;
95 u32 m_initDelay;
96 f32 m_poleScale;
97 s32 m_eruptUpDuration;
98 s32 m_eruptDownDuration;
99 std::array<s32, 6> m_stateStart;
100 f32 m_eruptDownVel;
101 f32 m_initScaledHeight;
102 s32 m_cycleFrame;
104 f32 m_scaledHeight;
106 f32 m_eruptAccel;
107 f32 m_initEruptVel;
108
109 static u32 FLAMEPOLE_COUNT;
110
111 static constexpr std::array<StateManagerEntry, 6> STATE_ENTRIES = {{
112 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterExpanding,
113 &ObjectFlamePoleFoot::calcExpanding>(0)},
114 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterEruptingUp,
115 &ObjectFlamePoleFoot::calcEruptingUp>(1)},
116 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterEruptingStay,
117 &ObjectFlamePoleFoot::calcEruptingStay>(2)},
118 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterEruptingDown,
119 &ObjectFlamePoleFoot::calcEruptingDown>(3)},
120 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterDormant,
121 &ObjectFlamePoleFoot::calcDormant>(4)},
122 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterState5,
123 &ObjectFlamePoleFoot::calcState5>(5)},
124 }};
125
126 static constexpr u32 CYCLE_FRAMES = 540;
127};
128
129} // namespace Field
A 3 x 4 matrix.
Definition Matrix.hh:8
Represents the geysers on Bowser's Castle.
u32 m_extraCycleFrames
Used to increase the animation cycle beyond the typical 540 frames.
f32 m_scaleDelta
Change in scale per frame at end of cycle.
f32 m_heightOffset
Cyclical offset that adjusts the pole's height.
The flamepole that erupts from a geyser on Bowser's Castle.
Base class that represents different "states" for an object.
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88