SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
CoinHolder.cpp
1#include "Game/MapObj/CoinHolder.hpp"
2#include "Game/MapObj/Coin.hpp"
3
4CoinHolder::CoinHolder(const char *pName) : DeriveActorGroup<Coin>(pName, 0x200), mHostInfoArr(nullptr), mHostInfoCount(0) {
5 mHostInfoArr = new CoinHostInfo[0x200];
6}
7
8bool CoinHolder::hopCoin(const NameObj *pObj, const TVec3f &a2, const TVec3f &a3) {
9 CoinHostInfo* hostInfo = findHostInfo(pObj);
10
11 if (hostInfo->_8 >= hostInfo->_4) {
12 return false;
13 }
14
15 Coin* coin = getDeadMember();
16
17 if (coin) {
18 coin->setHostInfo(hostInfo);
19 coin->appearHop(a2, a3);
20 return true;
21 }
22
23 return false;
24}
25
26bool CoinHolder::appearCoinFix(const NameObj *pObj, const TVec3f &a2, s32 a3) {
27 TVec3f stack_8(0.0f, 0.0f, 0.0f);
28 return appearCoin(pObj, a2, stack_8, a3, -1, -1, a3 == 1 ? 0.0f : 4.0f);
29}
30
31bool CoinHolder::appearCoinPop(const NameObj *pObj, const TVec3f &a2, s32 a3) {
32 TVec3f stack_20;
33 MR::calcGravityVector(this, a2, &stack_20, nullptr, nullptr);
34 TVec3f stack_8 = -stack_20 % 25.0f;
35 return appearCoin(pObj, a2, stack_8, a3, -1, -1, a3 == 1 ? 0.0f : 4.0f);
36}
37
38bool CoinHolder::appearCoinToVelocity(const NameObj *pObj, const TVec3f &a2, const TVec3f &a3, s32 a4) {
39 return appearCoin(pObj, a2, a3, a4, -1, -1, a4 == 1 ? 0.0f : 4.0f);
40}
41
42// CoinHolder::appearCoinCircle
43
44CoinHostInfo* CoinHolder::declare(const NameObj *pObj, s32 a2) {
45 if (a2 < 0) {
46 return nullptr;
47 }
48
49 CoinHostInfo* hostInfo = findHostInfo(pObj);
50 if (!hostInfo) {
51 hostInfo = &mHostInfoArr[mHostInfoCount];
52 hostInfo->mHostActor = pObj;
53 mHostInfoCount++;
54 }
55
56 hostInfo->_4 += a2;
57 return hostInfo;
58}
59
60s32 CoinHolder::getDeclareRemnantCoinCount(const NameObj *pObj) const {
61 CoinHostInfo* hostInfo = findHostInfo(pObj);
62
63 if (MR::isGalaxyDarkCometAppearInCurrentStage()) {
64 return 0;
65 }
66
67 return hostInfo->_4 - hostInfo->_8;
68}
69
70CoinHostInfo* CoinHolder::findHostInfo(const NameObj *pObj) const {
71 for (s32 i = 0; i < mHostInfoCount; i++) {
72 if (mHostInfoArr[i].mHostActor == pObj) {
73 return &mHostInfoArr[i];
74 }
75 }
76
77 return nullptr;
78}
79
80void CoinHolder::init(const JMapInfoIter &rIter) {
81 for (int i = 0; i < 0x20; i++) {
82 Coin* coin = new Coin("コイン(共用)");
83 coin->initWithoutIter();
84 registerActor(coin);
85 }
86}
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
Definition Coin.hpp:23
The most basic form of an object.
Definition NameObj.hpp:11
void initWithoutIter()
Initializes a NameObj without a JMapInfoIter instance.
Definition NameObj.cpp:41