1#include "ObjectHeyhoBall.hh"
3#include "game/field/ObjectDirector.hh"
8ObjectHeyhoBall::ObjectHeyhoBall(
const System::MapdataGeoObj ¶ms)
10 m_airtime(static_cast<f32>(params.setting(1))), m_initPos(params.pos()) {
11 registerManagedObject();
15ObjectHeyhoBall::~ObjectHeyhoBall() =
default;
18void ObjectHeyhoBall::init() {
22 m_intensity = ExplosionIntensity::ExplosionLoseItem;
24 resize(BLAST_RADIUS, 0.0f);
26 const auto &flowTable = ObjectDirector::Instance()->flowTable();
27 m_blastRadiusRatio = BLAST_RADIUS /
28 static_cast<f32
>(parse<s16>(flowTable.set(flowTable.slot(
id()))->params.sphere.radius));
32Kart::Reaction ObjectHeyhoBall::onCollision(Kart::KartObject * ,
33 Kart::Reaction , Kart::Reaction ,
34 EGG::Vector3f &hitDepth) {
35 if (m_currentStateId == 3) {
36 if (m_intensity == ExplosionIntensity::ExplosionLoseItem) {
37 return Kart::Reaction::ExplosionLoseItem;
41 return Kart::Reaction::SpinSomeSpeed;
44 return Kart::Reaction::WallAllSpeed;
50 m_xzDir = (m_initPos + EGG::Vector3f::ey * -BALL_RADIUS) - m_shipPos;
55 m_xzSpeed = EGG::Mathf::sqrt(xzDist.dot()) /
m_airtime;
56 m_yDist = m_initPos.y + -BALL_RADIUS - m_shipPos.y;
61void ObjectHeyhoBall::enterFalling() {
64 resize(BLAST_RADIUS, 0.0f);
69void ObjectHeyhoBall::calcFalling() {
70 f32 currentHeight = m_workingPos.y + (m_initYSpeed - 4.0f *
static_cast<f32
>(m_currentFrame));
71 if (currentHeight > m_initPos.y + -BALL_RADIUS) {
72 m_workingPos.y = currentHeight;
73 m_workingPos.x += m_xzDir.x * m_xzSpeed;
74 m_workingPos.z += m_xzDir.z * m_xzSpeed;
77 m_workingPos = (m_workingPos + m_initPos + EGG::Vector3f::ey * -BALL_RADIUS) * 0.5f;
83 constexpr u32 EXPLODE_FRAMES = 46;
87 constexpr u32 SPIN_FRAME = 32;
89 if (m_currentFrame >= EXPLODE_FRAMES) {
93 unregisterCollision();
97 m_intensity = ExplosionIntensity::ExplosionLoseItem;
99 f32 shrinkFrames =
static_cast<f32
>(m_currentFrame) - 40.0f;
100 f32 scale = 1.2f *
m_blastRadiusRatio + -m_scaleChangeRate * shrinkFrames * shrinkFrames;
105 m_intensity = m_currentFrame >= SPIN_FRAME ? ExplosionIntensity::SpinSomeSpeed :
106 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.