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 Kinoko::Field {
8
9class ObjectFlamePole;
10
12class ObjectFlamePoleFoot final : public ObjectKCL, public StateManager {
13 friend class Host::Context;
14
15public:
17 ~ObjectFlamePoleFoot() override;
18
19 void init() override;
20 void calc() override;
21
23 [[nodiscard]] u32 loadFlags() const override {
24 return 1;
25 }
26
28 [[nodiscard]] f32 getCollisionRadius() const override {
29 return 245.0f * static_cast<f32>(m_mapObj->setting(2));
30 }
31
33 [[nodiscard]] const EGG::Matrix34f &getUpdatedMatrix(u32 /*timeOffset*/) override {
34 calcTransform();
35 m_workMatrix = m_transform;
36 return m_transform;
37 }
38
39 [[nodiscard]] f32 getScaleY(u32 timeOffset) const override;
40 [[nodiscard]] bool checkCollision(f32 radius, const EGG::Vector3f &pos,
41 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info,
42 KCLTypeMask *maskOut, u32 timeOffset) override;
43 [[nodiscard]] bool checkCollisionCached(f32 radius, const EGG::Vector3f &pos,
44 const EGG::Vector3f &prevPos, KCLTypeMask mask, CollisionInfo *info,
45 KCLTypeMask *maskOut, u32 timeOffset) override;
46
47private:
49 void enterExpanding() {
50 m_heightOffset = 0.0f;
51 }
52
53 void enterEruptingUp();
54
56 void enterEruptingStay() {
57 m_scaledHeight = m_initScaledHeight;
58 }
59
61 void enterEruptingDown() {
62 m_scaledHeight = m_heightOffset;
63 }
64
66 void enterDormant() {
67 m_pole->setActive(false);
68 m_pole->disableCollision();
69 }
70
72 void enterState5() {}
73
75 void calcExpanding() {}
76
77 void calcEruptingUp();
78 void calcEruptingStay();
79
81 void calcEruptingDown() {
83 m_scaledHeight - m_scaleDelta * static_cast<f32>(m_cycleFrame - m_stateStart[3]);
84 }
85
87 void calcDormant() {}
88
90 void calcState5() {}
91
92 void calcStates();
93
94 EGG::Matrix34f m_workMatrix;
95 ObjectFlamePole *m_pole;
97 u32 m_initDelay;
98 f32 m_poleScale;
99 s32 m_eruptUpDuration;
100 s32 m_eruptDownDuration;
101 std::array<s32, 6> m_stateStart;
102 f32 m_eruptDownVel;
103 f32 m_initScaledHeight;
104 s32 m_cycleFrame;
106 f32 m_scaledHeight;
108 f32 m_eruptAccel;
109 f32 m_initEruptVel;
110
111 static u32 s_flamePoleCount;
112
113 static constexpr std::array<StateManagerEntry, 6> STATE_ENTRIES = {{
114 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterExpanding,
115 &ObjectFlamePoleFoot::calcExpanding>(0)},
116 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterEruptingUp,
117 &ObjectFlamePoleFoot::calcEruptingUp>(1)},
118 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterEruptingStay,
119 &ObjectFlamePoleFoot::calcEruptingStay>(2)},
120 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterEruptingDown,
121 &ObjectFlamePoleFoot::calcEruptingDown>(3)},
122 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterDormant,
123 &ObjectFlamePoleFoot::calcDormant>(4)},
124 {StateEntry<ObjectFlamePoleFoot, &ObjectFlamePoleFoot::enterState5,
125 &ObjectFlamePoleFoot::calcState5>(5)},
126 }};
127
128 static constexpr u32 CYCLE_FRAMES = 540;
129};
130
131} // namespace Kinoko::Field
A 3 x 4 matrix.
Definition Matrix.hh:10
Represents the geysers on Bowser's Castle.
f32 m_scaleDelta
Change in scale per frame at end of cycle.
f32 m_heightOffset
Cyclical offset that adjusts the pole's height.
u32 m_extraCycleFrames
Used to increase the animation cycle beyond the typical 540 frames.
The flamepole that erupts from a geyser on Bowser's Castle.
Base class that represents different "states" for an object.
Contexts can be used to restore a previous memory state for the current session.
Definition Context.hh:71
Pertains to collision.
A 3D float vector.
Definition Vector.hh:107