SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
ClippingGroupHolder.cpp
1#include "Game/LiveActor/ClippingGroupHolder.hpp"
2#include "Game/LiveActor/ClippingActorInfo.hpp"
3#include "Game/LiveActor/LiveActor.hpp"
4
5ClippingInfoGroup::ClippingInfoGroup(const char *pGroupName, int count) : NameObj(pGroupName) {
6 _C = count;
7 _10 = 0;
8 _14 = 0;
9 _18 = 0;
10 _1C = 0;
11 _14 = new ClippingActorInfo*[count];
12
13 for (s32 i = 0; i < _C; i++) {
14 _14[i] = 0;
15 }
16}
17
18void ClippingInfoGroup::setGroupNo(const JMapInfoIter &rIter) {
19 _18 = new JMapIdInfo(MR::createJMapIdInfoFromClippingGroupId(rIter));
20}
21
22void ClippingInfoGroup::registerInfo(ClippingActorInfo *pInfo) {
23 _14[_10] = pInfo;
24 _10++;
25}
26
27bool ClippingInfoGroup::isClippedNowAll() const {
28 for (s32 i = 0; i < _10; i++) {
29 if (!MR::isDead(_14[i]->mActor)) {
30 if (MR::isInvalidClipping(_14[i]->mActor)) {
31 return false;
32 }
33
34 if (!_14[i]->isJudgedToClip()) {
35 return false;
36 }
37 }
38 }
39
40 return true;
41}
42
43void ClippingInfoGroup::startClippedAll() {
44 _1C = 1;
45
46 for (s32 i = 0; i < _10; i++) {
47 if (!MR::isDead(_14[i]->mActor) && !MR::isClipped(_14[i]->mActor)) {
48 _14[i]->mActor->startClipped();
49 }
50 }
51}
52
53void ClippingInfoGroup::endClippedAll() {
54 _1C = 0;
55
56 for (s32 i = 0; i < _10; i++) {
57 if (!MR::isDead(_14[i]->mActor) && MR::isClipped(_14[i]->mActor)) {
58 _14[i]->mActor->endClipped();
59 }
60 }
61}
62
63void ClippingGroupHolder::movement() {
64 ClippingInfoGroup* group;
65 for (s32 i = 0; i < mNumGroups; i++) {
66 group = mInfoGroups[i];
67
68 if (group->isClippedNowAll()) {
69 u8 var = group->_1C;
70 if (!var) {
71 group->startClippedAll();
72 }
73 }
74 else {
75 u8 var = group->_1C;
76 if (!var) {
77 group->endClippedAll();
78 }
79 }
80 }
81}
82
83void ClippingGroupHolder::createAndAdd(ClippingActorInfo *pInfo, const JMapInfoIter &rIter, int count) {
84 ClippingInfoGroup* group = findGroup(rIter);
85
86 if (!group) {
87 group = createGroup(pInfo, rIter, count);
88 }
89
90 group->registerInfo(pInfo);
91}
92
93ClippingInfoGroup* ClippingGroupHolder::createGroup(ClippingActorInfo *pInfo, const JMapInfoIter &rIter, int count) {
94 ClippingInfoGroup* group = new ClippingInfoGroup(pInfo->mActor->mName, count);
95 group->setGroupNo(rIter);
96 mInfoGroups[mNumGroups] = group;
97 mNumGroups++;
98 return group;
99}
100
101#ifdef NON_MATCHING
102// reg usage issue, and not reloading the array to return
103ClippingInfoGroup* ClippingGroupHolder::findGroup(const JMapInfoIter &rIter) {
104 JMapIdInfo info = MR::createJMapIdInfoFromClippingGroupId(rIter);
105
106 for (s32 i = 0; i < mNumGroups; i++) {
107 bool isFound = false;
108 JMapIdInfo* inf = mInfoGroups[i]->_18;
109
110 if (*inf == info) {
111 return mInfoGroups[i];
112 }
113 }
114
115 return 0;
116}
117#endif
118
119ClippingInfoGroup::~ClippingInfoGroup() {
120
121}
122
123ClippingGroupHolder::~ClippingGroupHolder() {
124
125}
126
127ClippingGroupHolder::ClippingGroupHolder() : NameObj("クリッピングアクター保持") {
128 mNumGroups = 0;
129 mInfoGroups = 0;
130 mInfoGroups = new ClippingInfoGroup*[0x40];
131
132 for (s32 i = 0; i < 0x40; i++) {
133 mInfoGroups[i] = 0;
134 }
135}
The most basic form of an object.
Definition NameObj.hpp:11
const char * mName
A string to identify the NameObj.
Definition NameObj.hpp:38