SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
LightZoneDataHolder.cpp
1#include "Game/AreaObj/LightArea.hpp"
2#include "Game/Map/LightZoneDataHolder.hpp"
3#include "Game/Map/LightFunction.hpp"
4#include "Game/Util.hpp"
5
6ZoneLightID::ZoneLightID() {
7 _0 = -1;
8 mLightID = -1;
9}
10
11void ZoneLightID::clear() {
12 _0 = -1;
13 mLightID = -1;
14}
15
16bool ZoneLightID::isTargetArea(const LightArea *pLightArea) const {
17 if (_0 == pLightArea->mPlacedZoneID && mLightID == pLightArea->mObjArg0) {
18 return false;
19 }
20
21 return true;
22}
23
24bool ZoneLightID::isOutOfArea() const {
25 return mLightID < 0;
26}
27
28LightZoneInfo::LightZoneInfo() {
29 mAreaCount = 0;
30 mAreaInfo = 0;
31}
32
33const char* LightZoneInfo::getAreaLightNameInZoneData(s32 idx) const {
34 for (int i = 0; i < mAreaCount; i++) {
35 if (mAreaInfo[i].mID == idx) {
36 return mAreaInfo[i].mAreaLightName;
37 }
38 }
39
40 return LightFunction::getDefaultAreaLightName();
41}
42
43LightZoneDataHolder::LightZoneDataHolder() {
44 mCount = 0;
45 mZoneInfo = 0;
46}
47
48void LightZoneDataHolder::initZoneData() {
49 mCount = MR::getZoneNum();
50 mZoneInfo = new LightZoneInfo[mCount];
51
52 for (s32 i = 0; i < mCount; i++) {
53 mZoneInfo[i].init(i);
54 }
55}
56
57const char* LightZoneDataHolder::getAreaLightNameInZoneData(const ZoneLightID &zoneID) const {
58 s32 val = zoneID._0;
59
60 if (val < 0) {
61 val = 0;
62 }
63
64 return mZoneInfo[val].getAreaLightNameInZoneData(zoneID.mLightID);
65}
66
67// this will load the first entry, but they will all return the same thing anyways
68const char* LightZoneDataHolder::getDefaultStageAreaLightName() const {
69 return mZoneInfo->getAreaLightNameInZoneData(-1);
70}
71
72void LightZoneInfo::init(s32 zoneID) {
73 const char* zoneName = MR::getZoneNameFromZoneId(zoneID);
74 JMapInfo* parser = 0;
75 mAreaCount = LightFunction::createZoneDataParser(zoneName, &parser);
76 mAreaInfo = new AreaInfo[mAreaCount];
77
78 for (int i = 0; i < mAreaCount; i++) {
79 AreaInfo* inf = &mAreaInfo[i];
80
81 MR::getCsvDataS32(&inf->mID, parser, "LightID", i);
82 MR::getCsvDataStr(&inf->mAreaLightName, parser, "AreaLightName", i);
83 }
84}