A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectVolcanoBall.hh
1#pragma once
2
3#include "game/field/StateManager.hh"
4#include "game/field/obj/ObjectCollidable.hh"
5
6namespace Field {
7
9class ObjectVolcanoBall final : public ObjectCollidable, public StateManager {
10 friend class ObjectVolcanoBallLauncher;
11
12public:
13 ObjectVolcanoBall(f32 accel, f32 finalVel, f32 endPosY, const System::MapdataGeoObj &params,
14 const EGG::Vector3f &vel);
15 ~ObjectVolcanoBall() override;
16
17 void init() override;
18
20 void calc() override {
21 StateManager::calc();
22 }
23
25 [[nodiscard]] u32 loadFlags() const override {
26 return 1;
27 }
28
30 Kart::Reaction onCollision(Kart::KartObject * /*kartObj*/, Kart::Reaction reactionOnKart,
31 Kart::Reaction /*reactionOnObj*/, EGG::Vector3f & /*hitDepth*/) override {
32 return reactionOnKart;
33 }
34
35private:
37 void enterState0() {
38 init();
39 }
40
42 void enterState1() {
43 init();
44 }
45
47 void enterState2() {}
48
50 void calcDormant() {}
51
52 void calcFalling();
53
55 void calcBurning() {
56 if (m_currentFrame >= m_burnDuration) {
57 m_nextStateId = 0;
58 }
59 }
60
62 const f32 m_accel;
63 const f32 m_finalVel;
64 const f32 m_endPosY;
65 const f32 m_sqVelXZ;
66
67 static constexpr std::array<StateManagerEntry, 3> STATE_ENTRIES = {{
68 {StateEntry<ObjectVolcanoBall, &ObjectVolcanoBall::enterState0,
69 &ObjectVolcanoBall::calcDormant>(0)},
70 {StateEntry<ObjectVolcanoBall, &ObjectVolcanoBall::enterState1,
71 &ObjectVolcanoBall::calcFalling>(1)},
72 {StateEntry<ObjectVolcanoBall, &ObjectVolcanoBall::enterState2,
73 &ObjectVolcanoBall::calcBurning>(2)},
74 }};
75};
76
77} // namespace Field
The manager class that launch fireballs on Grumble Volcano.
Represents a fireball that is launched from the volcanoes on Grumble Volcano.
const f32 m_finalVel
Velocity of the ball at the moment of impact.
const f32 m_sqVelXZ
Squared X-Z plane velocity.
const u16 m_burnDuration
How long the ball burns for before disappearing.
const f32 m_endPosY
Height of the ball at the end of its rail.
Base class that represents different "states" for an object.
The highest level abstraction for a kart.
Definition KartObject.hh:11
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88