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 Kinoko::Field {
7
9class ObjectHeyhoBall final : public ObjectProjectile, public StateManager {
10public:
11 ObjectHeyhoBall(const System::MapdataGeoObj &params);
12 ~ObjectHeyhoBall() override;
13
14 void init() override;
15
17 void calc() override {
18 StateManager::calc();
19 setPos(m_workingPos);
20 }
21
22 [[nodiscard]] Kart::Reaction onCollision(Kart::KartObject *kartObj,
23 Kart::Reaction reactionOnKart, Kart::Reaction reactionOnObj,
24 EGG::Vector3f &hitDepth) override;
25
27 [[nodiscard]] u32 loadFlags() const override {
28 return 1;
29 }
30
31 void initProjectile(const EGG::Vector3f &pos) override;
32
34 void onLaunch() override {
35 m_nextStateId = 1;
36 }
37
38 [[nodiscard]] f32 yDist() const {
39 return m_yDist;
40 }
41
42 [[nodiscard]] f32 initYSpeed() const {
43 return m_initYSpeed;
44 }
45
46private:
47 enum class ExplosionIntensity {
48 ExplosionLoseItem = 0,
49 SpinSomeSpeed = 1,
50 };
51
53 void enterIntangible() {}
54
55 void enterFalling();
56
58 void enterBlinking() {
59 m_workingPos = m_initPos + EGG::Vector3f::ey * -BALL_RADIUS;
60 }
61
63 void enterExploding() {
64 m_scaleChangeRate = (1.2f * m_blastRadiusRatio - 1.0f) / 40.0f / 40.0f;
65 }
66
68 void calcIntangible() {
69 m_workingPos = m_shipPos;
70 }
71
72 void calcFalling();
73
75 void calcBlinking() {
76 constexpr u32 REST_FRAMES = 180;
77
78 if (m_currentFrame >= REST_FRAMES) {
79 m_nextStateId = 3;
80 }
81 }
82
83 void calcExploding();
84
85 const f32 m_airtime;
86 EGG::Vector3f m_shipPos;
87 const EGG::Vector3f m_initPos;
88 EGG::Vector3f m_xzDir;
89 f32 m_yDist;
90 f32 m_xzSpeed;
91 f32 m_initYSpeed;
93 f32 m_scaleChangeRate;
94 EGG::Vector3f m_workingPos;
95 ExplosionIntensity m_intensity;
96
97 static constexpr f32 BALL_RADIUS = 50.0f;
98 static constexpr f32 BLAST_RADIUS = 1500.0f;
99
100 static constexpr std::array<StateManagerEntry, 4> STATE_ENTRIES = {{
101 {StateEntry<ObjectHeyhoBall, &ObjectHeyhoBall::enterIntangible,
102 &ObjectHeyhoBall::calcIntangible>(0)},
103 {StateEntry<ObjectHeyhoBall, &ObjectHeyhoBall::enterFalling,
104 &ObjectHeyhoBall::calcFalling>(1)},
105 {StateEntry<ObjectHeyhoBall, &ObjectHeyhoBall::enterBlinking,
106 &ObjectHeyhoBall::calcBlinking>(2)},
107 {StateEntry<ObjectHeyhoBall, &ObjectHeyhoBall::enterExploding,
109 }};
110};
111
112} // namespace Kinoko::Field
void initProjectile(const EGG::Vector3f &pos) override
Callback function called by the managing ObjectSniper.
f32 m_blastRadiusRatio
Ratio between the blast radius and the shell's radius.
const f32 m_airtime
Number of frames between shooting and landing.
void onLaunch() override
Callback function use by the ObjectSniper that wants to throw this projectile.
The highest level abstraction for a kart.
Definition KartObject.hh:11
Pertains to collision.
A 3D float vector.
Definition Vector.hh:107