System: Implement GameProgressData (#145)

This commit is contained in:
tetraxile 2024-08-30 22:28:23 +01:00 committed by GitHub
parent cbc54bedce
commit 50aa6ab85b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 602 additions and 76 deletions

View File

@ -33803,51 +33803,51 @@ Address,Quality,Size,Name
0x0000007100534524,U,000064,_ZN2rs33isNeedShowInformationPoleClimbTopEPKN2al18IUseSceneObjHolderE
0x0000007100534564,U,000056,_ZN2rs25isNeedConfirmNetworkFirstEPKN2al18IUseSceneObjHolderE
0x000000710053459c,U,000052,_ZN2rs23saveConfirmNetworkFirstEPKN2al18IUseSceneObjHolderE
0x00000071005345d0,U,000256,_ZN16GameProgressDataC1EPK9WorldList
0x00000071005346d0,U,000116,_ZN16GameProgressData4initEv
0x0000007100534744,U,001576,_ZN16GameProgressData10updateListEv
0x0000007100534d6c,U,000184,_ZN16GameProgressData27checkAndChangeCorrectStatusEii
0x0000007100534e24,U,000016,_ZNK16GameProgressData11isFindKoopaEv
0x0000007100534e34,U,000016,_ZNK16GameProgressData18isBossAttackedHomeEv
0x0000007100534e44,U,000016,_ZNK16GameProgressData14isActivateHomeEv
0x0000007100534e54,U,000024,_ZN16GameProgressData12activateHomeEv
0x0000007100534e6c,U,000016,_ZNK16GameProgressData12isLaunchHomeEv
0x0000007100534e7c,U,000024,_ZN16GameProgressData10launchHomeEv
0x0000007100534e94,U,000024,_ZN16GameProgressData9findKoopaEv
0x0000007100534eac,U,000016,_ZNK16GameProgressData11isCrashHomeEv
0x0000007100534ebc,U,000024,_ZN16GameProgressData9crashHomeEv
0x0000007100534ed4,U,000016,_ZNK16GameProgressData12isRepairHomeEv
0x0000007100534ee4,U,000024,_ZN16GameProgressData10repairHomeEv
0x0000007100534efc,U,000024,_ZN16GameProgressData14bossAttackHomeEv
0x0000007100534f14,U,000016,_ZNK16GameProgressData25isRepairHomeByCrashedBossEv
0x0000007100534f24,U,000024,_ZN16GameProgressData23repairHomeByCrashedBossEv
0x0000007100534f3c,U,000008,_ZNK16GameProgressData12getHomeLevelEv
0x0000007100534f44,U,000052,_ZN16GameProgressData11upHomeLevelEv
0x0000007100534f78,U,000008,_ZNK16GameProgressData17getUnlockWorldNumEv
0x0000007100534f80,U,000012,_ZNK16GameProgressData13isUnlockWorldEi
0x0000007100534f8c,U,000012,_ZNK16GameProgressData21getWorldIdForWorldMapEi
0x0000007100534f98,U,000028,_ZNK16GameProgressData33calcNextLockedWorldNumForWorldMapEv
0x0000007100534fb4,U,000120,_ZNK16GameProgressData32calcNextLockedWorldIdForWorldMapEi
0x000000710053502c,U,000016,_ZNK16GameProgressData19isUnlockFirstForestEv
0x000000710053503c,U,000024,_ZNK16GameProgressData16isUnlockFirstSeaEv
0x0000007100535054,U,000012,_ZNK16GameProgressData26getWorldIdForWorldWarpHoleEi
0x0000007100535060,U,000012,_ZNK16GameProgressData22getWorldIdForShineListEi
0x000000710053506c,U,000156,_ZNK16GameProgressData24calcWorldNumForShineListEv
0x0000007100535108,U,000020,_ZNK16GameProgressData16isAlreadyGoWorldEi
0x000000710053511c,U,000356,_ZN16GameProgressData15unlockNextWorldEi
0x0000007100535280,U,000032,_ZN16GameProgressData12unlockForestEv
0x00000071005352a0,U,000032,_ZN16GameProgressData10unlockLakeEv
0x00000071005352c0,U,000032,_ZN16GameProgressData10unlockSnowEv
0x00000071005352e0,U,000032,_ZN16GameProgressData9unlockSeaEv
0x0000007100535300,U,000016,_ZN16GameProgressData17unlockNormalWorldEv
0x0000007100535310,U,000012,_ZNK16GameProgressData18isFirstTimeGoWorldEi
0x000000710053531c,U,000012,_ZN16GameProgressData17setAlreadyGoWorldEi
0x0000007100535328,U,000016,_ZNK16GameProgressData30isTalkedCapNearHomeInWaterfallEv
0x0000007100535338,U,000024,_ZN16GameProgressData26talkCapNearHomeInWaterfallEv
0x0000007100535350,U,000260,_ZN16GameProgressData5writeEPN2al11ByamlWriterE
0x0000007100535454,U,000404,_ZN16GameProgressData4readERKN2al9ByamlIterE
0x00000071005355e8,U,000116,_ZN16GameProgressData8initListEv
0x000000710053565c,U,000232,_ZNK16GameProgressData24calcWorldIdByOrderUnlockEi
0x00000071005345d0,O,000256,_ZN16GameProgressDataC1EPK9WorldList
0x00000071005346d0,O,000116,_ZN16GameProgressData4initEv
0x0000007100534744,O,001576,_ZN16GameProgressData10updateListEv
0x0000007100534d6c,O,000184,_ZN16GameProgressData27checkAndChangeCorrectStatusEii
0x0000007100534e24,O,000016,_ZNK16GameProgressData11isFindKoopaEv
0x0000007100534e34,O,000016,_ZNK16GameProgressData18isBossAttackedHomeEv
0x0000007100534e44,O,000016,_ZNK16GameProgressData14isActivateHomeEv
0x0000007100534e54,O,000024,_ZN16GameProgressData12activateHomeEv
0x0000007100534e6c,O,000016,_ZNK16GameProgressData12isLaunchHomeEv
0x0000007100534e7c,O,000024,_ZN16GameProgressData10launchHomeEv
0x0000007100534e94,O,000024,_ZN16GameProgressData9findKoopaEv
0x0000007100534eac,O,000016,_ZNK16GameProgressData11isCrashHomeEv
0x0000007100534ebc,O,000024,_ZN16GameProgressData9crashHomeEv
0x0000007100534ed4,O,000016,_ZNK16GameProgressData12isRepairHomeEv
0x0000007100534ee4,O,000024,_ZN16GameProgressData10repairHomeEv
0x0000007100534efc,O,000024,_ZN16GameProgressData14bossAttackHomeEv
0x0000007100534f14,O,000016,_ZNK16GameProgressData25isRepairHomeByCrashedBossEv
0x0000007100534f24,O,000024,_ZN16GameProgressData23repairHomeByCrashedBossEv
0x0000007100534f3c,O,000008,_ZNK16GameProgressData12getHomeLevelEv
0x0000007100534f44,O,000052,_ZN16GameProgressData11upHomeLevelEv
0x0000007100534f78,O,000008,_ZNK16GameProgressData17getUnlockWorldNumEv
0x0000007100534f80,O,000012,_ZNK16GameProgressData13isUnlockWorldEi
0x0000007100534f8c,O,000012,_ZNK16GameProgressData21getWorldIdForWorldMapEi
0x0000007100534f98,O,000028,_ZNK16GameProgressData33calcNextLockedWorldNumForWorldMapEv
0x0000007100534fb4,O,000120,_ZNK16GameProgressData32calcNextLockedWorldIdForWorldMapEi
0x000000710053502c,O,000016,_ZNK16GameProgressData19isUnlockFirstForestEv
0x000000710053503c,O,000024,_ZNK16GameProgressData16isUnlockFirstSeaEv
0x0000007100535054,O,000012,_ZNK16GameProgressData26getWorldIdForWorldWarpHoleEi
0x0000007100535060,O,000012,_ZNK16GameProgressData22getWorldIdForShineListEi
0x000000710053506c,O,000156,_ZNK16GameProgressData24calcWorldNumForShineListEv
0x0000007100535108,O,000020,_ZNK16GameProgressData16isAlreadyGoWorldEi
0x000000710053511c,O,000356,_ZN16GameProgressData15unlockNextWorldEi
0x0000007100535280,O,000032,_ZN16GameProgressData12unlockForestEv
0x00000071005352a0,O,000032,_ZN16GameProgressData10unlockLakeEv
0x00000071005352c0,O,000032,_ZN16GameProgressData10unlockSnowEv
0x00000071005352e0,O,000032,_ZN16GameProgressData9unlockSeaEv
0x0000007100535300,O,000016,_ZN16GameProgressData17unlockNormalWorldEv
0x0000007100535310,O,000012,_ZNK16GameProgressData18isFirstTimeGoWorldEi
0x000000710053531c,O,000012,_ZN16GameProgressData17setAlreadyGoWorldEi
0x0000007100535328,O,000016,_ZNK16GameProgressData30isTalkedCapNearHomeInWaterfallEv
0x0000007100535338,O,000024,_ZN16GameProgressData26talkCapNearHomeInWaterfallEv
0x0000007100535350,O,000260,_ZN16GameProgressData5writeEPN2al11ByamlWriterE
0x0000007100535454,O,000404,_ZN16GameProgressData4readERKN2al9ByamlIterE
0x00000071005355e8,O,000116,_ZN16GameProgressData8initListEv
0x000000710053565c,O,000232,_ZNK16GameProgressData24calcWorldIdByOrderUnlockEi
0x0000007100535744,U,000080,_ZN10GameSystemC2Ev
0x0000007100535794,U,000152,_ZN10GameSystemD2Ev
0x000000710053582c,O,000036,_ZN10GameSystemD0Ev

Can't render this file because it is too large.

View File

@ -348,7 +348,7 @@ public:
static bool isUnlockedWorld(GameDataHolderAccessor, s32);
static bool isUnlockedNextWorld(GameDataHolderAccessor);
static bool isUnlockedAllWorld(GameDataHolderAccessor);
static void getWorldIndexSpecial2();
static s32 getWorldIndexSpecial2();
static bool isUnlockedCurrentWorld(GameDataHolderAccessor);
static bool isCollectShineForNextWorldAndNotUnlockNextWorld(const al::LiveActor*);
static void tryGetCurrentMainStageName(GameDataHolderAccessor);
@ -362,17 +362,17 @@ public:
static void tryFindWorldIdByMainStageName(const al::Scene*, const char*);
static void tryFindWorldIdByMainStageName(const al::IUseSceneObjHolder*, const char*);
static void checkEnableUnlockWorldSpecial1(const al::LiveActor*);
static void getWorldIndexSpecial1();
static s32 getWorldIndexSpecial1();
static void checkEnableUnlockWorldSpecial2(const al::LiveActor*);
static void tryGetWorldNameByFileId(const al::LayoutActor*, s32);
static bool isNewSaveDataByFileId(const al::LayoutActor*, s32);
static void getLastUpdateFileTime(const al::LayoutActor*, s32);
static void makeTextureSaveDataFileName(sead::BufferedSafeStringBase<char>*,
const nn::g3d::ResFile*, const GameDataHolder*, s32);
static void getWorldIndexPeach();
static void getWorldIndexCity();
static s32 getWorldIndexPeach();
static s32 getWorldIndexCity();
static bool isCityWorldCeremonyAll(s32, s32);
static void getWorldIndexSea();
static s32 getWorldIndexSea();
static void getUnlockWorldIdForWorldMap(const al::LayoutActor*, s32);
static void getUnlockWorldIdForWorldMap(const al::LiveActor*, s32);
static void getUnlockWorldIdForWorldMap(const al::Scene*, s32);
@ -495,16 +495,16 @@ public:
static bool isTalkedCapNearHomeInWaterfall(const al::LiveActor*);
static bool isFlagOnTalkMessageInfo(const al::IUseSceneObjHolder*, s32);
static void onFlagTalkMessageInfo(const al::IUseSceneObjHolder*, s32);
static void getWorldIndexHat();
static void getWorldIndexSand();
static void getWorldIndexForest();
static void getWorldIndexLake();
static void getWorldIndexCloud();
static void getWorldIndexClash();
static void getWorldIndexSnow();
static void getWorldIndexLava();
static void getWorldIndexBoss();
static void getWorldIndexSky();
static s32 getWorldIndexHat();
static s32 getWorldIndexSand();
static s32 getWorldIndexForest();
static s32 getWorldIndexLake();
static s32 getWorldIndexCloud();
static s32 getWorldIndexClash();
static s32 getWorldIndexSnow();
static s32 getWorldIndexLava();
static s32 getWorldIndexBoss();
static s32 getWorldIndexSky();
static bool isWorldCap(GameDataHolderAccessor);
static bool isWorldWaterfall(GameDataHolderAccessor);
static bool isWorldSand(GameDataHolderAccessor);

View File

@ -0,0 +1,434 @@
#include "System/GameProgressData.h"
#include "Library/Yaml/ByamlUtil.h"
#include "Library/Yaml/Writer/ByamlWriter.h"
#include "System/GameDataFunction.h"
#include "System/WorldList.h"
GameProgressData::GameProgressData(const WorldList* worldList) : mWorldList(worldList) {
s32 worldNum = worldList->getWorldNum();
mIsUnlockWorld = new bool[worldNum];
mWorldIdForWorldWarpHole = new s32[worldNum];
mWorldIdForShineList = new s32[worldNum];
mWorldIdForWorldMap = new s32[worldNum];
mIsFirstTimeWorld = new bool[worldNum];
init();
}
void GameProgressData::init() {
mHomeStatus = HomeStatus::None;
mHomeLevel = 0;
mUnlockWorldStatusFirstBranch = FirstBranch::None;
mUnlockWorldStatusSecondBranch = SecondBranch::None;
mUnlockWorldNum = 1;
mWaterfallWorldProgress = WaterfallWorldProgress::None;
for (s32 i = 0; i < mWorldList->getWorldNum(); i++)
mIsFirstTimeWorld[i] = true;
setAlreadyGoWorld(0);
updateList();
}
void GameProgressData::updateList() {
initList();
s32 worldNum = mWorldList->getWorldNum();
s32 idxPeach = mWorldList->tryFindWorldIndexByDevelopName("Peach");
for (s32 j = 0, i = 0; i < worldNum; i++) {
s32 worldId = calcWorldIdByOrderUnlock(i);
if (worldId == -1)
continue;
mIsUnlockWorld[worldId] = true;
if (++j == mUnlockWorldNum)
break;
}
s32 idxCloud = mWorldList->tryFindWorldIndexByDevelopName("Cloud");
s32 idxAttack = mWorldList->tryFindWorldIndexByDevelopName("Attack");
s32 idxCity = mWorldList->tryFindWorldIndexByDevelopName("City");
s32 idxSky = mWorldList->tryFindWorldIndexByDevelopName("Sky");
bool isUnlockPeach = mIsUnlockWorld[idxPeach];
for (s32 i = 0; i < worldNum; i++) {
s32 worldId = calcWorldIdByOrderUnlock(i);
if (worldId == -1)
continue;
if (isUnlockPeach) {
if (i == idxPeach)
mWorldIdForWorldMap[0] = idxPeach;
else {
if (worldId < idxPeach)
worldId++;
mWorldIdForWorldMap[worldId] = i;
}
} else {
if (worldId == idxCloud && mUnlockWorldNum == idxCloud + 1)
mWorldIdForWorldMap[worldId] = idxCity;
else if (worldId == idxAttack && mUnlockWorldNum == idxAttack + 1)
mWorldIdForWorldMap[worldId] = idxSky;
else
mWorldIdForWorldMap[i] = worldId;
}
}
for (s32 i = 0; i < worldNum; i++) {
s32 worldId = calcWorldIdByOrderUnlock(i);
if (worldId != -1) {
mWorldIdForWorldWarpHole[i] = worldId;
mWorldIdForShineList[i] = worldId;
}
}
if (isUnlockPeach) {
for (s32 i = 0; i < worldNum; i++)
if (i == idxPeach)
mWorldIdForShineList[0] = idxPeach;
else if (i < idxPeach)
mWorldIdForShineList[i + 1] = mWorldIdForWorldWarpHole[i];
else
mWorldIdForShineList[i] = mWorldIdForWorldWarpHole[i];
}
}
void GameProgressData::checkAndChangeCorrectStatus(s32 worldId, s32 nextScenarioNo) {
if (worldId == GameDataFunction::getWorldIndexWaterfall() && nextScenarioNo > 1)
mWaterfallWorldProgress = WaterfallWorldProgress::TalkedCapNearHome;
if (worldId > GameDataFunction::getWorldIndexWaterfall())
mWaterfallWorldProgress = WaterfallWorldProgress::TalkedCapNearHome;
if (worldId == GameDataFunction::getWorldIndexHat() && nextScenarioNo > 1)
mWaterfallWorldProgress = WaterfallWorldProgress::TalkedCapNearHome;
if (worldId != GameDataFunction::getWorldIndexCloud() && isFindKoopa())
mHomeStatus = HomeStatus::LaunchedHome;
if (worldId != GameDataFunction::getWorldIndexBoss() && isBossAttackedHome())
mHomeStatus = HomeStatus::RepairedHome;
}
bool GameProgressData::isFindKoopa() const {
return mHomeStatus == HomeStatus::FoundKoopa;
}
bool GameProgressData::isBossAttackedHome() const {
return mHomeStatus == HomeStatus::BossAttackedHome;
}
bool GameProgressData::isActivateHome() const {
return mHomeStatus > HomeStatus::None;
}
void GameProgressData::activateHome() {
if (mHomeStatus < HomeStatus::ActivatedHome)
mHomeStatus = HomeStatus::ActivatedHome;
}
bool GameProgressData::isLaunchHome() const {
return mHomeStatus > HomeStatus::ActivatedHome;
}
void GameProgressData::launchHome() {
if (mHomeStatus < HomeStatus::LaunchedHome)
mHomeStatus = HomeStatus::LaunchedHome;
}
void GameProgressData::findKoopa() {
if (mHomeStatus < HomeStatus::FoundKoopa)
mHomeStatus = HomeStatus::FoundKoopa;
}
bool GameProgressData::isCrashHome() const {
return mHomeStatus == HomeStatus::CrashedHome;
}
void GameProgressData::crashHome() {
if (mHomeStatus < HomeStatus::CrashedHome)
mHomeStatus = HomeStatus::CrashedHome;
}
bool GameProgressData::isRepairHome() const {
return mHomeStatus > HomeStatus::CrashedHome;
}
void GameProgressData::repairHome() {
if (mHomeStatus < HomeStatus::RepairedHome)
mHomeStatus = HomeStatus::RepairedHome;
}
void GameProgressData::bossAttackHome() {
if (mHomeStatus < HomeStatus::BossAttackedHome)
mHomeStatus = HomeStatus::BossAttackedHome;
}
bool GameProgressData::isRepairHomeByCrashedBoss() const {
return mHomeStatus > HomeStatus::BossAttackedHome;
}
void GameProgressData::repairHomeByCrashedBoss() {
if (mHomeStatus < HomeStatus::RepairedHomeByCrashedBoss)
mHomeStatus = HomeStatus::RepairedHomeByCrashedBoss;
}
s32 GameProgressData::getHomeLevel() const {
return mHomeLevel;
}
void GameProgressData::upHomeLevel() {
s32 nextHomeLevels[18] = {0, 0, 1, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 9, 9, 9, 9, 9};
s32 nextHomeLevel = nextHomeLevels[mUnlockWorldNum];
nextHomeLevel = sead::Mathi::min(nextHomeLevel, mHomeLevel + 1);
mHomeLevel = sead::Mathi::clampMax(nextHomeLevel, 9);
}
s32 GameProgressData::getUnlockWorldNum() const {
return mUnlockWorldNum;
}
bool GameProgressData::isUnlockWorld(s32 idx) const {
return mIsUnlockWorld[idx];
}
s32 GameProgressData::getWorldIdForWorldMap(s32 idx) const {
return mWorldIdForWorldMap[idx];
}
s32 GameProgressData::calcNextLockedWorldNumForWorldMap() const {
if (mUnlockWorldNum == 3 || mUnlockWorldNum == 8)
return 2;
else
return 1;
}
s32 GameProgressData::calcNextLockedWorldIdForWorldMap(s32 idx) const {
switch (mUnlockWorldNum) {
case 3:
return idx == 0 ? GameDataFunction::getWorldIndexForest() :
GameDataFunction::getWorldIndexLake();
case 4:
return isUnlockFirstForest() ? GameDataFunction::getWorldIndexLake() :
GameDataFunction::getWorldIndexForest();
case 5:
return GameDataFunction::getWorldIndexCity();
case 8:
return idx != 0 ? GameDataFunction::getWorldIndexSnow() :
GameDataFunction::getWorldIndexSea();
case 9:
return isUnlockFirstSea() ? GameDataFunction::getWorldIndexSea() :
GameDataFunction::getWorldIndexSnow();
case 11:
return GameDataFunction::getWorldIndexSky();
default:
return mUnlockWorldNum;
}
}
bool GameProgressData::isUnlockFirstForest() const {
if (mUnlockWorldStatusFirstBranch == FirstBranch::None ||
mUnlockWorldStatusFirstBranch == FirstBranch::Forest)
return true;
return false;
}
bool GameProgressData::isUnlockFirstSea() const {
if (mUnlockWorldStatusSecondBranch == SecondBranch::None ||
mUnlockWorldStatusSecondBranch == SecondBranch::Sea)
return true;
return false;
}
s32 GameProgressData::getWorldIdForWorldWarpHole(s32 idx) const {
return mWorldIdForWorldWarpHole[idx];
}
s32 GameProgressData::getWorldIdForShineList(s32 idx) const {
return mWorldIdForShineList[idx];
}
s32 GameProgressData::calcWorldNumForShineList() const {
s32 idxSpecial2 = GameDataFunction::getWorldIndexSpecial2();
if (isUnlockWorld(idxSpecial2) && isAlreadyGoWorld(idxSpecial2))
return mWorldList->getWorldNum();
s32 worldNum = 0;
for (s32 i = 0; i < mWorldList->getWorldNum(); i++)
worldNum += isAlreadyGoWorld(i);
return worldNum;
}
bool GameProgressData::isAlreadyGoWorld(s32 idx) const {
return !mIsFirstTimeWorld[idx];
}
void GameProgressData::unlockNextWorld(s32 idx) {
while (true) {
updateList();
if (isUnlockWorld(idx))
return;
s32 idxForest = mWorldList->tryFindWorldIndexByDevelopName("Forest");
s32 idxLake = mWorldList->tryFindWorldIndexByDevelopName("Lake");
s32 idxSnow = mWorldList->tryFindWorldIndexByDevelopName("Snow");
s32 idxSea = mWorldList->tryFindWorldIndexByDevelopName("Sea");
if (idx == idxForest)
unlockForest();
else if (idx == idxLake)
unlockLake();
else if (idx == idxSnow)
unlockSnow();
else if (idx == idxSea)
unlockSea();
else
unlockNormalWorld();
updateList();
s32 nextHomeLevels[17] = {0, 0, 1, 2, 2, 4, 4, 4, 5, 5, 7, 8, 8, 9, 9, 9, 9};
mHomeLevel = sead::Mathi::max(mHomeLevel, nextHomeLevels[idx]);
if (mHomeLevel == 9)
mHomeStatus = HomeStatus::RepairedHomeByCrashedBoss;
if (isUnlockWorld(idx))
return;
}
}
void GameProgressData::unlockForest() {
if (mUnlockWorldStatusFirstBranch == FirstBranch::None)
mUnlockWorldStatusFirstBranch = FirstBranch::Forest;
mUnlockWorldNum++;
}
void GameProgressData::unlockLake() {
if (mUnlockWorldStatusFirstBranch == FirstBranch::None)
mUnlockWorldStatusFirstBranch = FirstBranch::Lake;
mUnlockWorldNum++;
}
void GameProgressData::unlockSnow() {
if (mUnlockWorldStatusSecondBranch == SecondBranch::None)
mUnlockWorldStatusSecondBranch = SecondBranch::Snow;
mUnlockWorldNum++;
}
void GameProgressData::unlockSea() {
if (mUnlockWorldStatusSecondBranch == SecondBranch::None)
mUnlockWorldStatusSecondBranch = SecondBranch::Sea;
mUnlockWorldNum++;
}
void GameProgressData::unlockNormalWorld() {
mUnlockWorldNum++;
}
bool GameProgressData::isFirstTimeGoWorld(s32 idx) const {
return mIsFirstTimeWorld[idx];
}
void GameProgressData::setAlreadyGoWorld(s32 idx) {
mIsFirstTimeWorld[idx] = false;
}
bool GameProgressData::isTalkedCapNearHomeInWaterfall() const {
return mWaterfallWorldProgress > WaterfallWorldProgress::GotFirstMoon;
}
void GameProgressData::talkCapNearHomeInWaterfall() {
if (mWaterfallWorldProgress < WaterfallWorldProgress::TalkedCapNearHome)
mWaterfallWorldProgress = WaterfallWorldProgress::TalkedCapNearHome;
}
void GameProgressData::write(al::ByamlWriter* writer) {
writer->pushHash("GameProgressData");
writer->addInt("HomeStatus", (s32)mHomeStatus);
writer->addInt("HomeLevel", mHomeLevel);
writer->addInt("UnlockWorldNum", mUnlockWorldNum);
writer->addInt("UnlockWorldStatusFirstBranch", (s32)mUnlockWorldStatusFirstBranch);
writer->addInt("UnlockWorldStatusSecondBranch", (s32)mUnlockWorldStatusSecondBranch);
writer->addInt("WaterfallWorldProgress", (s32)mWaterfallWorldProgress);
writer->pushArray("IsFirstTimeWorld");
for (s32 i = 0; i < mWorldList->getWorldNum(); i++)
writer->addBool(isFirstTimeGoWorld(i));
writer->pop();
writer->pop();
}
void GameProgressData::read(const al::ByamlIter& iter) {
init();
al::ByamlIter hash;
iter.tryGetIterByKey(&hash, "GameProgressData");
hash.tryGetIntByKey((s32*)&mHomeStatus, "HomeStatus");
hash.tryGetIntByKey(&mHomeLevel, "HomeLevel");
hash.tryGetIntByKey(&mUnlockWorldNum, "UnlockWorldNum");
hash.tryGetIntByKey((s32*)&mUnlockWorldStatusFirstBranch, "UnlockWorldStatusFirstBranch");
hash.tryGetIntByKey((s32*)&mUnlockWorldStatusSecondBranch, "UnlockWorldStatusSecondBranch");
hash.tryGetIntByKey((s32*)&mWaterfallWorldProgress, "WaterfallWorldProgress");
al::ByamlIter array;
hash.tryGetIterByKey(&array, "IsFirstTimeWorld");
for (s32 i = 0; i < mWorldList->getWorldNum(); i++)
array.tryGetBoolByIndex(&mIsFirstTimeWorld[i], i);
updateList();
}
void GameProgressData::initList() {
for (s32 i = 0; i < mWorldList->getWorldNum(); i++) {
mIsUnlockWorld[i] = false;
mWorldIdForWorldMap[i] = -1;
mWorldIdForWorldWarpHole[i] = -1;
mWorldIdForShineList[i] = -1;
}
}
s32 GameProgressData::calcWorldIdByOrderUnlock(s32 idx) const {
s32 idxForest = mWorldList->tryFindWorldIndexByDevelopName("Forest");
s32 idxLake = mWorldList->tryFindWorldIndexByDevelopName("Lake");
s32 idxSnow = mWorldList->tryFindWorldIndexByDevelopName("Snow");
s32 idxSea = mWorldList->tryFindWorldIndexByDevelopName("Sea");
if (idx == idxForest)
return mUnlockWorldStatusFirstBranch < FirstBranch::Lake ? idx : idxLake;
if (idx == idxLake)
return mUnlockWorldStatusFirstBranch < FirstBranch::Lake ? idx : idxForest;
if (idx == idxSnow) {
if (mUnlockWorldStatusSecondBranch != SecondBranch::None &&
mUnlockWorldStatusSecondBranch != SecondBranch::Sea)
return idxSea;
else
return idx;
}
if (idx == idxSea) {
if (mUnlockWorldStatusSecondBranch != SecondBranch::None &&
mUnlockWorldStatusSecondBranch != SecondBranch::Sea)
return idxSnow;
else
return idx;
}
return idx;
}

View File

@ -1,8 +1,100 @@
#pragma once
class GameProgressData {
#include <basis/seadTypes.h>
#include "System/ByamlSave.h"
class WorldList;
class GameProgressData : public ByamlSave {
public:
enum class FirstBranch : u32 {
None = 0,
Forest = 1,
Lake = 2,
};
enum class SecondBranch : u32 {
None = 0,
Sea = 3,
Snow = 4,
};
enum class HomeStatus : s32 {
None = 0,
ActivatedHome = 1,
LaunchedHome = 2,
FoundKoopa = 3,
CrashedHome = 4,
RepairedHome = 5,
BossAttackedHome = 6,
RepairedHomeByCrashedBoss = 7,
};
enum class WaterfallWorldProgress : s32 {
None = 0,
GotFirstMoon = 1,
TalkedCapNearHome = 2,
};
void write(al::ByamlWriter* writer) override;
void read(const al::ByamlIter& iter) override;
GameProgressData(const WorldList* worldList);
void init();
void updateList();
void checkAndChangeCorrectStatus(s32 worldId, s32 nextScenarioNo);
bool isFindKoopa() const;
bool isBossAttackedHome() const;
bool isActivateHome() const;
void activateHome();
bool isLaunchHome() const;
void launchHome();
void findKoopa();
bool isCrashHome() const;
void crashHome();
bool isRepairHome() const;
void repairHome();
void bossAttackHome();
bool isRepairHomeByCrashedBoss() const;
void repairHomeByCrashedBoss();
s32 getHomeLevel() const;
void upHomeLevel();
s32 getUnlockWorldNum() const;
bool isUnlockWorld(s32 idx) const;
s32 getWorldIdForWorldMap(s32 idx) const;
s32 calcNextLockedWorldNumForWorldMap() const;
s32 calcNextLockedWorldIdForWorldMap(s32 idx) const;
bool isUnlockFirstForest() const;
bool isUnlockFirstSea() const;
s32 getWorldIdForWorldWarpHole(s32 idx) const;
s32 getWorldIdForShineList(s32 idx) const;
s32 calcWorldNumForShineList() const;
bool isAlreadyGoWorld(s32 idx) const;
void unlockNextWorld(s32 idx);
void unlockForest();
void unlockLake();
void unlockSnow();
void unlockSea();
void unlockNormalWorld();
bool isFirstTimeGoWorld(s32 idx) const;
void setAlreadyGoWorld(s32 idx);
bool isTalkedCapNearHomeInWaterfall() const;
void talkCapNearHomeInWaterfall();
void initList();
s32 calcWorldIdByOrderUnlock(s32 idx) const;
private:
s32* mWorldIdForWorldMap = nullptr;
s32* mWorldIdForWorldWarpHole = nullptr;
s32* mWorldIdForShineList = nullptr;
bool* mIsUnlockWorld = nullptr;
s32 mUnlockWorldNum = 1;
FirstBranch mUnlockWorldStatusFirstBranch = FirstBranch::None;
SecondBranch mUnlockWorldStatusSecondBranch = SecondBranch::None;
HomeStatus mHomeStatus = HomeStatus::None;
s32 mHomeLevel = 0;
const WorldList* mWorldList = nullptr;
bool* mIsFirstTimeWorld = nullptr;
WaterfallWorldProgress mWaterfallWorldProgress = WaterfallWorldProgress::None;
};

View File

@ -28,24 +28,24 @@ class WorldList {
public:
WorldList();
void getWorldNum();
void getMainQuestMin(s32, s32);
s32 getWorldNum() const;
s32 getMainQuestMin(s32, s32) const;
const char* getMainStageName(s32) const;
s32 tryFindWorldIndexByMainStageName(const char* stageName) const;
s32 tryFindWorldIndexByStageName(const char* stageName) const;
s32 tryFindWorldIndexByDevelopName(const char* stageName) const;
void isEqualClearMainScenarioNo(s32, s32);
void getAfterEndingScenarioNo(s32);
void isEqualAfterEndingScenarioNo(s32, s32);
s32 getMoonRockScenarioNo(s32 worldId) const;
s32 tryFindWorldIndexByMainStageName(const char*) const;
s32 tryFindWorldIndexByStageName(const char*) const;
s32 tryFindWorldIndexByDevelopName(const char*) const;
bool isEqualClearMainScenarioNo(s32, s32) const;
s32 getAfterEndingScenarioNo(s32) const;
bool isEqualAfterEndingScenarioNo(s32, s32) const;
s32 getMoonRockScenarioNo(s32) const;
bool isEqualMoonRockScenarioNo(s32, s32) const;
const char* getWorldDevelopName(s32) const;
void getWorldScenarioNum(s32);
s32 findUseScenarioNo(const char* stageName) const;
void checkNeedTreasureMessageStage(const char*);
bool checkIsMainStage(const char* stageName) const;
void tryFindTransOnMainStageByStageName(sead::Vector3f*, const char*, s32);
void tryFindHintTransByScenarioNo(sead::Vector3f*, s32, s32);
s32 getWorldScenarioNum(s32) const;
s32 findUseScenarioNo(const char*) const;
bool checkNeedTreasureMessageStage(const char*) const;
bool checkIsMainStage(const char*) const;
bool tryFindTransOnMainStageByStageName(sead::Vector3f*, const char*, s32) const;
bool tryFindHintTransByScenarioNo(sead::Vector3f*, s32, s32) const;
private:
sead::PtrArray<WorldListEntry> mWorldList;