A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectHeyhoBall.hh
1#pragma once
2
3#include "game/field/StateManager.hh"
4#include "game/field/obj/ObjectProjectile.hh"
5
6namespace Field {
7
9class ObjectHeyhoBall final : public ObjectProjectile, public StateManager {
10public:
12 ~ObjectHeyhoBall() override;
13
14 void init() override;
15 void calc() override;
16
17 [[nodiscard]] Kart::Reaction onCollision(Kart::KartObject *kartObj,
18 Kart::Reaction reactionOnKart, Kart::Reaction reactionOnObj,
19 EGG::Vector3f &hitDepth) override;
20
22 [[nodiscard]] u32 loadFlags() const override {
23 return 1;
24 }
25
26 void initProjectile(const EGG::Vector3f &pos) override;
27
29 void onLaunch() override {
30 m_nextStateId = 1;
31 }
32
33 [[nodiscard]] f32 yDist() const {
34 return m_yDist;
35 }
36
37 [[nodiscard]] f32 initYSpeed() const {
38 return m_initYSpeed;
39 }
40
41private:
42 enum class ExplosionIntensity {
43 ExplosionLoseItem = 0,
44 SpinSomeSpeed = 1,
45 };
46
48 void enterIntangible() {}
49
50 void enterFalling();
51
53 void enterBlinking() {
54 m_workingPos = m_initPos + EGG::Vector3f::ey * -BALL_RADIUS;
55 }
56
58 void enterExploding() {
59 m_scaleChangeRate = (1.2f * m_blastRadiusRatio - 1.0f) / 40.0f / 40.0f;
60 }
61
63 void calcIntangible() {
64 m_workingPos = m_shipPos;
65 }
66
67 void calcFalling();
68
70 void calcBlinking() {
71 constexpr u32 REST_FRAMES = 180;
72
73 if (m_currentFrame >= REST_FRAMES) {
74 m_nextStateId = 3;
75 }
76 }
77
78 void calcExploding();
79
80 const f32 m_airtime;
81 EGG::Vector3f m_shipPos;
82 const EGG::Vector3f m_initPos;
83 EGG::Vector3f m_xzDir;
84 f32 m_yDist;
85 f32 m_xzSpeed;
86 f32 m_initYSpeed;
88 f32 m_scaleChangeRate;
89 EGG::Vector3f m_workingPos;
90 ExplosionIntensity m_intensity;
91
92 static constexpr f32 BALL_RADIUS = 50.0f;
93 static constexpr f32 BLAST_RADIUS = 1500.0f;
94
95 static constexpr std::array<StateManagerEntry, 4> STATE_ENTRIES = {{
96 {StateEntry<ObjectHeyhoBall, &ObjectHeyhoBall::enterIntangible,
97 &ObjectHeyhoBall::calcIntangible>(0)},
98 {StateEntry<ObjectHeyhoBall, &ObjectHeyhoBall::enterFalling,
99 &ObjectHeyhoBall::calcFalling>(1)},
100 {StateEntry<ObjectHeyhoBall, &ObjectHeyhoBall::enterBlinking,
101 &ObjectHeyhoBall::calcBlinking>(2)},
102 {StateEntry<ObjectHeyhoBall, &ObjectHeyhoBall::enterExploding,
104 }};
105};
106
107} // namespace Field
The cannonball projectiles on GBA Shy Guy Beach.
void onLaunch() override
Callback function use by the ObjectSniper that wants to throw this projectile.
f32 m_blastRadiusRatio
Ratio between the blast radius and the shell's radius.
void initProjectile(const EGG::Vector3f &pos) override
Callback function called by the managing ObjectSniper.
const f32 m_airtime
Number of frames between shooting and landing.
Abstract class that represents an object thrown by an ObjectProjectileLauncher.
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