diff options
author | Treeki <treeki@gmail.com> | 2013-02-28 05:55:10 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2013-02-28 05:55:10 +0100 |
commit | 306549db49e602e0c6fd02a282f779e254f371c1 (patch) | |
tree | d49a6f65806e61a388a2d3a2ac448cc0d24a1074 /src/koopatlas/pathmanager.cpp | |
parent | b376ded880b4c863adfbe99ef04155d492e82c01 (diff) | |
download | kamek-306549db49e602e0c6fd02a282f779e254f371c1.tar.gz kamek-306549db49e602e0c6fd02a282f779e254f371c1.zip |
camera panning onto unlocked paths, among other fancy stuff and fixes
Diffstat (limited to 'src/koopatlas/pathmanager.cpp')
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 202 |
1 files changed, 167 insertions, 35 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 89b9f59..48590f9 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -50,12 +50,14 @@ void dWMPathManager_c::setup() { levelStartWait = -1; unlockPaths(); - waitForAfterDeathAnim = -1; - mustPlayAfterDeathAnim = false; + waitAfterInitialPlayerAnim = -1; if (LastPowerupStoreType == LOSE_LEVEL) { mustPlayAfterDeathAnim = true; daWMPlayer_c::instance->visible = false; LastPowerupStoreType = BEAT_LEVEL; + } else if (LastPowerupStoreType == BEAT_LEVEL && LastLevelPlayed[0] != 0xFF) { + mustPlayAfterWinAnim = true; + daWMPlayer_c::instance->visible = false; } SpammyReport("done\n"); @@ -78,7 +80,7 @@ void dWMPathManager_c::setup() { found = true; currentNode = node; - //OSReport("Found CHANGE node: %d %p\n", changeID, node); + SpammyReport("Found CHANGE node: %d %p\n", changeID, node); // figure out where we should move to dKPPath_s *exitTo = 0; @@ -237,6 +239,8 @@ void dWMPathManager_c::setup() { if (wm->isAfterKamekCutscene) copyWorldDefToSave(wm->mapData.findWorldDef(1)); + + finalisePathUnlocks(); } static u8 *PathAvailabilityData = 0; @@ -505,10 +509,13 @@ void dWMPathManager_c::unlockPaths() { node->setLayerAlpha((node->isUnlocked() & !node->isNew) ? 255 : 0); } +} +void dWMPathManager_c::finalisePathUnlocks() { // if anything was new, set it as such if (newlyAvailablePaths || newlyAvailableNodes) { countdownToFadeIn = 30; + findCameraBoundsForUnlockedPaths(); } unlockingAlpha = -1; } @@ -592,7 +599,9 @@ bool dWMPathManager_c::evaluateUnlockCondition(u8 *&in, SaveBlock *save, int sta bool dWMPathManager_c::doingThings() { if (isEnteringLevel || (waitAfterUnlock > 0) || (completionAnimDelay > 0) || - (waitAtStart > 0) || (waitForAfterDeathAnim > 0) || + (waitAtStart > 0) || (waitAfterInitialPlayerAnim > 0) || + panningCameraToPaths || panningCameraFromPaths || + (waitBeforePanBack > 0) || (countdownToFadeIn > 0) || (unlockingAlpha != -1)) return true; @@ -613,11 +622,52 @@ void dWMPathManager_c::execute() { return; } + if (waitAtStart > 0) { + waitAtStart--; + if (waitAtStart == 0) { + if (mustPlayAfterDeathAnim) { + daWMPlayer_c::instance->visible = true; + daWMPlayer_c::instance->startAnimation(ending_wait, 1.0f, 0.0f, 0.0f); + waitAfterInitialPlayerAnim = 60; + + nw4r::snd::SoundHandle something; + PlaySoundWithFunctionB4(SoundRelatedClass, &something, SE_VOC_MA_CS_COURSE_MISS, 1); + } else if (mustPlayAfterWinAnim) { + daWMPlayer_c::instance->visible = true; + daWMPlayer_c::instance->startAnimation(dm_surp_wait, 1.0f, 0.0f, 0.0f); + waitAfterInitialPlayerAnim = 38; + + nw4r::snd::SoundHandle something; + PlaySoundWithFunctionB4(SoundRelatedClass, &something, SE_VOC_MA_CS_JUMP, 1); + } + } + return; + } + + if (waitAfterInitialPlayerAnim > 0) { + waitAfterInitialPlayerAnim--; + if (waitAfterInitialPlayerAnim == 0) + daWMPlayer_c::instance->startAnimation(wait_select, 1.0f, 0.0f, 0.0f); + if (mustPlayAfterWinAnim && (waitAfterInitialPlayerAnim == 9)) { + nw4r::snd::SoundHandle something; + PlaySoundWithFunctionB4(SoundRelatedClass, &something, SE_PLY_LAND_ROCK, 1); + } + return; + } + + // handle path fading if (countdownToFadeIn > 0) { countdownToFadeIn--; if (countdownToFadeIn <= 0) { - unlockingAlpha = 0; + if (camBoundsValid) { + dWorldCamera_c::instance->currentX = currentNode->x; + dWorldCamera_c::instance->currentY = -currentNode->y; + dWorldCamera_c::instance->panToBounds(camMinX, camMinY, camMaxX, camMaxY); + + panningCameraToPaths = true; + } else + unlockingAlpha = 0; nw4r::snd::SoundHandle something; PlaySoundWithFunctionB4(SoundRelatedClass, &something, SE_OBJ_GEN_LOAD, 1); @@ -626,6 +676,13 @@ void dWMPathManager_c::execute() { } } + if (panningCameraToPaths) { + if (dWorldCamera_c::instance->panning) + return; + panningCameraToPaths = false; + unlockingAlpha = 0; + } + if (unlockingAlpha != -1) { unlockingAlpha += 3; @@ -648,6 +705,7 @@ void dWMPathManager_c::execute() { unlockingAlpha = -1; nw4r::snd::SoundHandle something; PlaySoundWithFunctionB4(SoundRelatedClass, &something, SE_OBJ_GEN_NEW_COURSE, 1); + waitAfterUnlock = 15; for (int i = 0; i < pathLayer->nodeCount; i++) { @@ -667,16 +725,36 @@ void dWMPathManager_c::execute() { if (waitAfterUnlock > 0) { waitAfterUnlock--; + if (waitAfterUnlock == 0) + waitBeforePanBack = 20; return; } + if (waitBeforePanBack > 0) { + waitBeforePanBack--; + if (waitBeforePanBack == 0 && camBoundsValid) { + dWorldCamera_c::instance->panToPosition( + currentNode->x, -currentNode->y, + STD_ZOOM); + panningCameraFromPaths = true; + } + } + + if (panningCameraFromPaths) { + if (dWorldCamera_c::instance->panning) + return; + panningCameraFromPaths = false; + dWorldCamera_c::instance->followPlayer = true; + } + + if (dmGladDuration > 0) { + dmGladDuration--; + if (dmGladDuration == 0) + daWMPlayer_c::instance->startAnimation(wait_select, 1.0f, 0.0f, 0.0f); + } + if (completionAnimDelay > 0) { completionAnimDelay--; - if (dmGladDuration > 0) { - dmGladDuration--; - if (dmGladDuration == 0) - daWMPlayer_c::instance->startAnimation(wait_select, 1.0f, 0.0f, 0.0f); - } if (completionAnimDelay == 0) completionMessagePending = true; return; @@ -710,35 +788,17 @@ void dWMPathManager_c::execute() { return; } - if (waitAtStart > 0) { - waitAtStart--; - if (waitAtStart == 0) { - if (mustPlayAfterDeathAnim) { - daWMPlayer_c::instance->visible = true; - daWMPlayer_c::instance->startAnimation(ending_wait, 1.0f, 0.0f, 0.0f); - waitForAfterDeathAnim = 60; - - nw4r::snd::SoundHandle something; - PlaySoundWithFunctionB4(SoundRelatedClass, &something, SE_VOC_MA_CS_COURSE_MISS, 1); - } - - dScKoopatlas_c::instance->startMusic(); - } - return; - } - - if (waitForAfterDeathAnim > 0) { - waitForAfterDeathAnim--; - if (waitForAfterDeathAnim == 0) - daWMPlayer_c::instance->startAnimation(wait_select, 1.0f, 0.0f, 0.0f); - return; - } - if (shouldRequestSave) { dScKoopatlas_c::instance->showSaveWindow(); shouldRequestSave = false; } + if (!initialLoading) { + dScKoopatlas_c::instance->startMusic(); + dWMHud_c::instance->loadInitially(); + initialLoading = true; + } + int nowPressed = Remocon_GetPressed(GetActiveRemocon()); // Left, right, up, down @@ -1191,7 +1251,7 @@ void dWMPathManager_c::moveThroughPath(int pressedDir) { } else if (reallyStop) { // Stop here - player->startAnimation(0, 1.2, 10.0, 0.0); + player->startAnimation(wait_select, 1.2, 10.0, 0.0); player->hasEffect = false; player->hasSound = false; @@ -1314,3 +1374,75 @@ void dWMPathManager_c::unlockAllPaths(char type) { } + + +void dWMPathManager_c::findCameraBoundsForUnlockedPaths() { + dKPMapData_c *data = &dScKoopatlas_c::instance->mapData; + + camMinX = 10000; + camMaxX = 0; + camMinY = 10000; + camMaxY = 0; + + nodeStackLength = 0; + for (int i = 0; i < data->pathLayer->nodeCount; i++) + data->pathLayer->nodes[i]->reserved1 = false; + + visitNodeForCamCheck(currentNode); + OSReport("Worked out camera bounds: %d,%d to %d,%d with validity %d\n", camMinX, camMinY, camMaxX, camMaxY, camBoundsValid); +} + +void dWMPathManager_c::visitNodeForCamCheck(dKPNode_s *node) { + // Yay. + nodeStackLength++; + node->reserved1 = true; + + for (int i = 0; i < 4; i++) { + dKPPath_s *path = node->exits[i]; + if (!path) + continue; + + OSReport("Checking path %p, whose status is %d\n", path, path->isAvailable); + if (path->isAvailable == dKPPath_s::NEWLY_AVAILABLE) { + addNodeToCameraBounds(path->start); + addNodeToCameraBounds(path->end); + } + + // Should we follow the other node? + dKPNode_s *otherNode = path->getOtherNodeTo(node); + + if (otherNode->reserved1) + continue; + if (otherNode->type == otherNode->LEVEL) { + OSReport("Not travelling to %p because it's level %d-%d\n", otherNode, otherNode->levelNumber[0], otherNode->levelNumber[1]); + continue; + } + if (otherNode->type == otherNode->CHANGE) { + OSReport("Not travelling to %p because it's a change\n", otherNode); + continue; + } + if (otherNode->type == otherNode->WORLD_CHANGE) { + OSReport("Not travelling to %p because it's a world change\n", otherNode); + continue; + } + + visitNodeForCamCheck(otherNode); + } + + nodeStackLength--; +} + +void dWMPathManager_c::addNodeToCameraBounds(dKPNode_s *node) { + camBoundsValid = true; + OSReport("Adding node to camera bounds: %p at %d,%d\n", node, node->x, node->y); + + if (node->x < camMinX) + camMinX = node->x; + if (node->x > camMaxX) + camMaxX = node->x; + if (node->y < camMinY) + camMinY = node->y; + if (node->y > camMaxY) + camMaxY = node->y; +} + |