1#include "ObjectHeyhoBall.hh"
3#include "game/field/ObjectDirector.hh"
5#include "game/kart/Reaction.hh"
10ObjectHeyhoBall::ObjectHeyhoBall(
const System::MapdataGeoObj ¶ms)
12 m_airtime(static_cast<f32>(params.setting(1))), m_initPos(params.pos()) {
13 registerManagedObject();
17ObjectHeyhoBall::~ObjectHeyhoBall() =
default;
20void ObjectHeyhoBall::init() {
24 m_intensity = ExplosionIntensity::ExplosionLoseItem;
26 resize(BLAST_RADIUS, 0.0f);
28 const auto &flowTable = ObjectDirector::Instance()->flowTable();
29 m_blastRadiusRatio = BLAST_RADIUS /
30 static_cast<f32
>(parse<s16>(flowTable.set(flowTable.slot(
id()))->params.sphere.radius));
34Kart::Reaction ObjectHeyhoBall::onCollision(Kart::KartObject * ,
35 Kart::Reaction , Kart::Reaction ,
36 EGG::Vector3f &hitDepth) {
37 if (m_currentStateId == 3) {
38 if (m_intensity == ExplosionIntensity::ExplosionLoseItem) {
39 return Kart::Reaction::ExplosionLoseItem;
43 return Kart::Reaction::SpinSomeSpeed;
46 return Kart::Reaction::WallAllSpeed;
52 m_xzDir = (m_initPos + EGG::Vector3f::ey * -BALL_RADIUS) - m_shipPos;
57 m_xzSpeed = EGG::Mathf::sqrt(xzDist.dot()) /
m_airtime;
58 m_yDist = m_initPos.y + -BALL_RADIUS - m_shipPos.y;
63void ObjectHeyhoBall::enterFalling() {
66 resize(BLAST_RADIUS, 0.0f);
71void ObjectHeyhoBall::calcFalling() {
72 f32 currentHeight = m_workingPos.y + (m_initYSpeed - 4.0f *
static_cast<f32
>(m_currentFrame));
73 if (currentHeight > m_initPos.y + -BALL_RADIUS) {
74 m_workingPos.y = currentHeight;
75 m_workingPos.x += m_xzDir.x * m_xzSpeed;
76 m_workingPos.z += m_xzDir.z * m_xzSpeed;
79 m_workingPos = (m_workingPos + m_initPos + EGG::Vector3f::ey * -BALL_RADIUS) * 0.5f;
85 constexpr u32 EXPLODE_FRAMES = 46;
89 constexpr u32 SPIN_FRAME = 32;
91 if (m_currentFrame >= EXPLODE_FRAMES) {
95 unregisterCollision();
99 m_intensity = ExplosionIntensity::ExplosionLoseItem;
101 f32 shrinkFrames =
static_cast<f32
>(m_currentFrame) - 40.0f;
102 f32 scale = 1.2f *
m_blastRadiusRatio + -m_scaleChangeRate * shrinkFrames * shrinkFrames;
107 m_intensity = m_currentFrame >= SPIN_FRAME ? ExplosionIntensity::SpinSomeSpeed :
108 ExplosionIntensity::ExplosionLoseItem;
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.
Abstract class that represents an object thrown by an ObjectProjectileLauncher.
Base class that represents different "states" for an object.