1#include "ObjectHeyhoShipManager.hh"
3#include "game/field/ObjectDirector.hh"
4#include "game/field/RailManager.hh"
5#include "game/field/obj/ObjectHeyhoShip.hh"
10ObjectHeyhoShipManager::ObjectHeyhoShipManager() {
11 auto &managedObjs = ObjectDirector::Instance()->managedObjects();
13 for (
auto *&obj : managedObjs) {
14 if (strcmp(obj->getName(),
"HeyhoBallGBA") == 0) {
19 m_projectiles = owning_span<ObjectProjectile *>(count);
21 for (
auto *&obj : managedObjs) {
22 if (strcmp(obj->getName(),
"HeyhoBallGBA") == 0) {
23 m_projectiles[curIdx++] =
reinterpret_cast<ObjectProjectile *
>(obj);
24 }
else if (strcmp(obj->getName(),
"HeyhoShipGBA") == 0) {
25 m_launcher =
reinterpret_cast<ObjectProjectileLauncher *
>(obj);
29 u16 pointCount = m_launcher->railInterpolator()->pointCount();
30 m_pointIdxs = owning_span<s16>(pointCount);
34ObjectHeyhoShipManager::~ObjectHeyhoShipManager() =
default;
39 constexpr f32 PROJECTILE_ANGLE = F_PI / 2.0f;
40 constexpr EGG::Vector3f HEIGHT_OFFSET = EGG::Vector3f::ey * 1600.0f;
41 constexpr f32 FORWARD_OFFSET = 1200.0f;
42 constexpr f32 LATERAL_OFFSET = 700.0f;
44 const auto *launcherRailInterp = m_launcher->railInterpolator();
45 for (
u16 i = 0; i < launcherRailInterp->pointCount(); ++i) {
49 for (
size_t i = 0; i < m_projectiles.size(); ++i) {
50 m_pointIdxs[m_projectiles[i]->idx()] = i;
54 auto *launcherRail = RailManager::Instance()->rail(launcherRailInterp->railIdx());
55 for (
auto *&obj : m_projectiles) {
56 const s16 idx = obj->idx();
57 const auto &dir = ship->initRailDir(idx);
59 EGG::Vector3f posOffset = forward + HEIGHT_OFFSET - dir * LATERAL_OFFSET;
60 EGG::Vector3f shipPos = launcherRail->pointPos(idx) + posOffset;
62 obj->initProjectile(shipPos);
69void ObjectHeyhoShipManager::calc() {
73 s16 pointIdx = m_pointIdxs[idx];
76 m_projectiles[pointIdx]->onLaunch();
static EGG::Vector3f RotateXZByYaw(f32 angle, const EGG::Vector3f &v)
Rotates a vector around the Y-axis and returns the XZ-plane portion of the vector.
The ship on GBA Shy Guy Beach that shoots cannonballs.
virtual s16 launchPointIdx()=0
Used by ObjectSniper to check which object (if any) should be thrown.