| 1 | #include "System/GameDataFile.h" |
| 2 | |
| 3 | #include "Library/Base/StringUtil.h" |
| 4 | |
| 5 | #include "System/GameDataFunction.h" |
| 6 | #include "System/GameProgressData.h" |
| 7 | |
| 8 | // NON_MATCHING |
| 9 | void GameDataFile::HintInfo::clear() { |
| 10 | mStageName.clear(); |
| 11 | mObjId.clear(); |
| 12 | // mScenarioName.clear(); |
| 13 | mObjectName = nullptr; |
| 14 | mTrans = sead::Vector3f::zero; |
| 15 | mTransAgain = sead::Vector3f::zero; |
| 16 | mMainScenarioNo = -1; |
| 17 | mWorldIndex = -1; |
| 18 | mUniqueID = -1; |
| 19 | mIsMoonRock = false; |
| 20 | unkBool1 = false; |
| 21 | unkPtr6 = nullptr; |
| 22 | mHintStatus = HintStatus::NONE; |
| 23 | mIsAchievement = false; |
| 24 | mIsGrand = false; |
| 25 | unkInt3 = 0; |
| 26 | mIsShopMoon = false; |
| 27 | mHintIdx = 0; |
| 28 | |
| 29 | mOptionalID.clear(); |
| 30 | mProgressBitflag = 0; |
| 31 | unkBool2 = 0; |
| 32 | unkBool3 = 0; |
| 33 | } |
| 34 | |
| 35 | bool GameDataFile::HintInfo::isDisableByWorldWarpHole(bool condition) const { |
| 36 | if (!condition && al::isEqualString(str1: mOptionalID.cstr(), str2: "WorldWarpHoleShine" )) |
| 37 | return true; |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | bool GameDataFile::HintInfo::isEnableUnlock(s32 curWorldId, bool isGameClear, s32 scenarioNo, |
| 42 | bool isInWorld) const { |
| 43 | if (testFunc(curWorldId, isGameClear, scenarioNo, isInWorld)) { |
| 44 | if (unkBool1) |
| 45 | return false; |
| 46 | |
| 47 | if (mHintStatus == HintStatus::NONE) |
| 48 | return true; |
| 49 | |
| 50 | if (isGameClear && mIsMoonRock) |
| 51 | return false; |
| 52 | else if (!isGameClear && mIsMoonRock) |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | return false; |
| 57 | } |
| 58 | |
| 59 | bool GameDataFile::HintInfo::isHintStatusUnlock(s32 curWorldId, s32 scenarioNo, |
| 60 | bool isInWorld) const { |
| 61 | if (mWorldIndex != curWorldId || unkBool1 || mHintStatus != HintStatus::NONE || |
| 62 | (isInWorld ? !mIsMoonRock : mIsMoonRock)) |
| 63 | return false; |
| 64 | |
| 65 | return !GameDataFunction::isCityWorldCeremonyAll(worldId: curWorldId, scenarioNo) || unkBool3; |
| 66 | } |
| 67 | |
| 68 | bool GameDataFile::HintInfo::isHintStatusUnlockByNpc() const { |
| 69 | return mHintStatus == HintStatus::NPC && !mIsMoonRock; |
| 70 | } |
| 71 | |
| 72 | bool GameDataFile::HintInfo::isHintStatusUnlockByAmiibo() const { |
| 73 | return mHintStatus == HintStatus::AMIIBO; |
| 74 | } |
| 75 | |
| 76 | bool GameDataFile::HintInfo::isEnableNameUnlockByScenario(s32 curWorldId, s32 scenarioNo, |
| 77 | bool isInWorld) const { |
| 78 | if (isDisableByWorldWarpHole(condition: isInWorld)) |
| 79 | return false; |
| 80 | if (mWorldIndex != curWorldId || unkBool2) |
| 81 | return false; |
| 82 | if (mProgressBitflag.countOnBit()) |
| 83 | return mProgressBitflag.isOnBit(bit: scenarioNo - 1); |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | bool GameDataFile::HintInfo::testFunc(s32 curWorldId, bool isGameClear, s32 scenarioNo, |
| 88 | bool isInWorld) const { |
| 89 | if (isDisableByWorldWarpHole(condition: isInWorld)) |
| 90 | return false; |
| 91 | if (mWorldIndex != curWorldId || unkBool2 || isGameClear) |
| 92 | return false; |
| 93 | if (mProgressBitflag.countOnBit()) |
| 94 | return mProgressBitflag.isOnBit(bit: scenarioNo - 1); |
| 95 | return true; |
| 96 | } |
| 97 | |
| 98 | bool GameDataFile::isGameClear() const { |
| 99 | return isUnlockedWorld(index: GameDataFunction::getWorldIndexPeach()) && |
| 100 | isAlreadyGoWorld(index: GameDataFunction::getWorldIndexPeach()); |
| 101 | } |
| 102 | |
| 103 | bool GameDataFile::isUnlockedWorld(s32 index) const { |
| 104 | return mGameProgressData->isUnlockWorld(idx: index); |
| 105 | } |
| 106 | |
| 107 | bool GameDataFile::isAlreadyGoWorld(s32 index) const { |
| 108 | return mGameProgressData->isAlreadyGoWorld(idx: index); |
| 109 | } |
| 110 | |