1#include "ObjectHeyhoShip.hh"
6ObjectHeyhoShip::ObjectHeyhoShip(
const System::MapdataGeoObj ¶ms)
8 m_yAmplitude(static_cast<f32>(static_cast<s16>(params.setting(1)))), m_frame(0) {
9 registerManagedObject();
13ObjectHeyhoShip::~ObjectHeyhoShip() =
default;
16void ObjectHeyhoShip::init() {
17 m_railInterpolator->init(0.0f, 0);
18 m_railInterpolator->setPerPointVelocities(
true);
19 setPos(m_railInterpolator->curPos());
21 const EGG::Vector3f &railTan = m_railInterpolator->curTangentDir();
22 EGG::Vector3f tangent = EGG::Vector3f(railTan.x, 0.0f, railTan.z);
24 tangent = RotateXZByYaw(F_PI / 2.0f, tangent);
26 if (EGG::Mathf::abs(tangent.y) > 0.1f) {
30 if (tangent.squaredLength() > std::numeric_limits<f32>::epsilon()) {
33 tangent = EGG::Vector3f::ey;
36 m_framesSinceLastLaunch = 1000;
37 setMatrixTangentTo(EGG::Vector3f::ey, tangent);
41void ObjectHeyhoShip::calc() {
42 if (m_railInterpolator->calc() == RailInterpolator::Status::SegmentEnd) {
43 m_framesSinceLastLaunch = 0;
45 ++m_framesSinceLastLaunch;
52void ObjectHeyhoShip::calcPos() {
53 constexpr f32 PERIOD = 100.0f;
55 setPos(m_railInterpolator->curPos());
57 f32 fidx = DEG2FIDX * (360.0f *
static_cast<f32
>(++m_frame) / PERIOD);
58 f32 posY = m_yAmplitude * EGG::Mathf::SinFIdx(fidx) + pos().y;
59 setPos(EGG::Vector3f(pos().x, posY, pos().z));
Abstract class that moves along its own rail and throws projectiles.