SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
SkeletalFishBossFunc.cpp
1#include "Game/Boss/SkeletalFishBossFunc.hpp"
2#include "Game/Util.hpp"
3#include <cstdio>
4
5namespace {
6 static const char* sNamePosName = "ガード出現ポイント";
7};
8
9s32 SkeletalFishBossFunc::getNearestGuardPosID(const TVec3f &rVec) {
10 f32 closest = 100000.0;
11 s32 posID = -1;
12
13 for (int i = 0; i < 16; i++) {
14 TVec3f pos;
15 if (copyGuardPos(&pos, i)) {
16 f32 dist = PSVECDistance(rVec.toCVec(), pos.toCVec());
17
18 if (dist < closest) {
19 closest = dist;
20 posID = i;
21 }
22 }
23 }
24
25 return posID;
26}
27
28bool SkeletalFishBossFunc::copyGuardPos(TVec3f *pOut, s32 idx) {
29 char buf[0x80];
30 snprintf(buf, sizeof(buf), "%s%d", ::sNamePosName, idx);
31 return MR::tryFindNamePos(buf, pOut, nullptr);
32}