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 = std::span<ObjectProjectile *>(
new ObjectProjectile *[count], 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 = std::span<s16>(
new s16[pointCount], pointCount);
34ObjectHeyhoShipManager::~ObjectHeyhoShipManager() {
35 delete[] m_projectiles.data();
36 delete[] m_pointIdxs.data();
42 constexpr f32 PROJECTILE_ANGLE = F_PI / 2.0f;
43 constexpr EGG::Vector3f HEIGHT_OFFSET = EGG::Vector3f::ey * 1600.0f;
44 constexpr f32 FORWARD_OFFSET = 1200.0f;
45 constexpr f32 LATERAL_OFFSET = 700.0f;
47 const auto *launcherRailInterp = m_launcher->railInterpolator();
48 for (
u16 i = 0; i < launcherRailInterp->pointCount(); ++i) {
52 for (
size_t i = 0; i < m_projectiles.size(); ++i) {
53 m_pointIdxs[m_projectiles[i]->idx()] = i;
57 auto *launcherRail = RailManager::Instance()->rail(launcherRailInterp->railIdx());
58 for (
auto *&obj : m_projectiles) {
59 const s16 idx = obj->idx();
60 const auto &dir = ship->initRailDir(idx);
62 EGG::Vector3f posOffset = forward + HEIGHT_OFFSET - dir * LATERAL_OFFSET;
63 EGG::Vector3f shipPos = launcherRail->pointPos(idx) + posOffset;
65 obj->initProjectile(shipPos);
72void ObjectHeyhoShipManager::calc() {
76 s16 pointIdx = m_pointIdxs[idx];
79 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.