diff --git a/data b/data index b26170a..c08b221 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit b26170ae9513ded1bb38dcb6fa537a1a6c02a9df +Subproject commit c08b221aed4d3dbe82e8ffe5bc67d7b786993b28 diff --git a/src/game/colony.hpp b/src/game/colony.hpp index c3eb958..2c57c38 100644 --- a/src/game/colony.hpp +++ b/src/game/colony.hpp @@ -50,6 +50,10 @@ public: void queryAnts(const BoundingVolume& volume, std::list* results) const; + std::size_t getAntCount() const; + const Ant* getAnt(std::size_t index) const; + Ant* getAnt(std::size_t index); + const Octree* getAntOctree() const; const Octree* getPheromoneOctree() const; @@ -83,6 +87,22 @@ inline Model* Colony::getAntModel() return antModel; } +inline std::size_t Colony::getAntCount() const +{ + return ants.size(); +} + +inline const Ant* Colony::getAnt(std::size_t index) const +{ + return ants[index]; +} + +inline Ant* Colony::getAnt(std::size_t index) +{ + return ants[index]; +} + + inline const Octree* Colony::getAntOctree() const { return antOctree; diff --git a/src/states/level-select-state.cpp b/src/states/level-select-state.cpp index 12921ca..e96ac74 100644 --- a/src/states/level-select-state.cpp +++ b/src/states/level-select-state.cpp @@ -109,6 +109,8 @@ void LevelSelectState::exit() application->defaultLayer->removeObject(surfaceInstance); application->defaultLayer->removeObject(subsurfaceInstance); } + application->defaultLayer->removeObject(&application->biomeFloorModelInstance); + application->levelIDLabel->setVisible(false); application->levelNameLabel->setVisible(false); } diff --git a/src/states/main-menu-state.cpp b/src/states/main-menu-state.cpp index f942bf8..284896d 100644 --- a/src/states/main-menu-state.cpp +++ b/src/states/main-menu-state.cpp @@ -18,6 +18,7 @@ */ #include "main-menu-state.hpp" +#include "title-state.hpp" #include "../application.hpp" #include "../debug.hpp" #include "../camera-controller.hpp" @@ -235,7 +236,7 @@ void MainMenuState::execute() } else if (application->menuCancel.isTriggered() && !application->menuCancel.wasTriggered()) { - + application->changeState(application->titleState); } float lineHeight = application->menuFont->getMetrics().getHeight(); @@ -277,7 +278,10 @@ void MainMenuState::execute() void MainMenuState::exit() { - // Remove nest + // Hide UI + application->menuSelectorLabel->setVisible(false); + + // Clear scene application->defaultLayer->removeObject(&application->nestModelInstance); } diff --git a/src/states/play-state.cpp b/src/states/play-state.cpp index 5930455..1b8dc6a 100644 --- a/src/states/play-state.cpp +++ b/src/states/play-state.cpp @@ -18,6 +18,7 @@ */ #include "play-state.hpp" +#include "level-select-state.hpp" #include "../application.hpp" #include "../camera-controller.hpp" #include "../game/colony.hpp" @@ -47,13 +48,10 @@ void PlayState::enter() // Setup tools application->forcepsClosed = false; - // Add background - //application->backgroundLayer->addObject(&application->bgCamera); - //application->backgroundLayer->addObject(&application->bgBatch); - // Add terrain to scene application->defaultLayer->addObject(&application->currentLevel->terrainSurface); application->defaultLayer->addObject(&application->currentLevel->terrainSubsurface); + application->defaultLayer->addObject(&application->biomeFloorModelInstance); // Add forceps to scene application->defaultLayer->addObject(&application->forcepsModelInstance); @@ -116,7 +114,11 @@ void PlayState::execute() //application->blaImage->setRotation(iconRotation); - + // Return to level select + if (application->menuCancel.isTriggered() && !application->menuCancel.wasTriggered()) + { + application->changeState(application->levelSelectState); + } // Move camera Vector2 movementVector(0.0f); @@ -217,11 +219,29 @@ void PlayState::execute() void PlayState::exit() { - // Remove background - //application->backgroundLayer->removeObject(&application->bgCamera); - //application->backgroundLayer->removeObject(&application->bgBatch); - + // Remove input observers application->mouse->removeMouseButtonObserver(this); + + // Clear scene + application->defaultLayer->removeObject(&application->currentLevel->terrainSurface); + application->defaultLayer->removeObject(&application->currentLevel->terrainSubsurface); + application->defaultLayer->removeObject(&application->biomeFloorModelInstance); + application->defaultLayer->removeObject(&application->forcepsModelInstance); + for (std::size_t i = 0; i < application->colony->getAntCount(); ++i) + { + Ant* ant = application->colony->getAnt(i); + application->defaultLayer->removeObject(ant->getModelInstance()); + } + + // Hide HUD + application->pauseButtonImage->setVisible(false); + application->pauseButtonImage->setActive(false); + application->playButtonImage->setVisible(false); + application->playButtonImage->setActive(false); + application->rectangularPaletteImage->setVisible(false); + application->rectangularPaletteImage->setActive(false); + application->toolbar->getContainer()->setVisible(false); + application->toolbar->getContainer()->setActive(false); } void PlayState::mouseButtonPressed(int button, int x, int y) diff --git a/src/states/title-state.cpp b/src/states/title-state.cpp index 45d19f6..192d13c 100644 --- a/src/states/title-state.cpp +++ b/src/states/title-state.cpp @@ -169,16 +169,18 @@ void TitleState::execute() void TitleState::exit() { + // Remove input observers + application->inputManager->removeWindowObserver(this); + + // Hide UI application->titleImage->setVisible(false); application->anyKeyLabel->setVisible(false); application->titleScreenInfoContainer->setVisible(false); - // Remove objects from scene + // Remove clear scene application->defaultLayer->removeObject(&application->antHillModelInstance); application->backgroundLayer->removeObject(&application->bgCamera); application->backgroundLayer->removeObject(&application->bgBatch); - - application->inputManager->removeWindowObserver(this); } void TitleState::windowClosed()