Move menu layers outside of world
This commit is contained in:
+45
-38
@@ -2,7 +2,10 @@
|
||||
Module : Dodge.Update
|
||||
Description : Simulation update
|
||||
-}
|
||||
module Dodge.Update (update) where
|
||||
module Dodge.Update
|
||||
(update
|
||||
,updateUniverse
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Hammer
|
||||
import Dodge.Block
|
||||
@@ -27,47 +30,51 @@ import Control.Lens
|
||||
import Data.Monoid
|
||||
import System.Random
|
||||
|
||||
updateUniverse :: Universe -> Universe
|
||||
updateUniverse w = case _menuLayers w of
|
||||
(TerminalScreen t xs:mls) -> w & menuLayers .~ (TerminalScreen (max (t-1) 0) xs:mls)
|
||||
(WaitScreen s i : _)
|
||||
| i < 1 -> w & over uvWorld (dbArg _worldEvents)
|
||||
| otherwise -> w & menuLayers %~ ( (WaitScreen s (i-1) :) . tail )
|
||||
(OptionScreen {_scOptionFlag = GameOverOptions} : _) ->
|
||||
-- updateParticles
|
||||
-- . updateProjectiles
|
||||
-- . updateLightSources
|
||||
-- $ updateClouds
|
||||
w
|
||||
(_ : _) -> w
|
||||
[] -> over uvWorld update w
|
||||
|
||||
update :: World -> World
|
||||
update = (frameClock +~ 1) . functionalUpdate
|
||||
{- | The update step.
|
||||
For most menus the only way to change the world is using event handling. -}
|
||||
functionalUpdate :: World -> World
|
||||
functionalUpdate w = case _menuLayers w of
|
||||
(TerminalScreen t xs:mls) -> w & menuLayers .~ (TerminalScreen (max (t-1) 0) xs:mls)
|
||||
(WaitScreen s i : _)
|
||||
| i < 1 -> w & dbArg _worldEvents
|
||||
| otherwise -> w & menuLayers %~ ( (WaitScreen s (i-1) :) . tail )
|
||||
(OptionScreen {_scOptionFlag = GameOverOptions} : _) -> updateParticles
|
||||
. updateProjectiles
|
||||
. updateLightSources
|
||||
$ updateClouds
|
||||
w
|
||||
(_ : _) -> w
|
||||
[] -> checkEndGame
|
||||
. updateDistortions
|
||||
. updateCreatureSoundPositions
|
||||
. ppEvents
|
||||
. updateCamera
|
||||
. colCrsWalls
|
||||
-- . ifConfigWallRotate
|
||||
. simpleCrSprings
|
||||
. zoneCreatures
|
||||
. updateDoors
|
||||
. resetWorldEvents
|
||||
. dbArg _worldEvents
|
||||
. updateModifications
|
||||
. updateParticles
|
||||
. updateProjectiles
|
||||
. updateLightSources
|
||||
. updateClouds
|
||||
. zoneClouds
|
||||
. updateMachines
|
||||
. updateCreatures
|
||||
. updateCreatureGroups
|
||||
. updateBlocks
|
||||
. updateSeenWalls
|
||||
. (lSelHammerPosition %~ moveHammerUp)
|
||||
$ updateCloseObjects w
|
||||
functionalUpdate w = checkEndGame
|
||||
. updateDistortions
|
||||
. updateCreatureSoundPositions
|
||||
. ppEvents
|
||||
. updateCamera
|
||||
. colCrsWalls
|
||||
-- . ifConfigWallRotate
|
||||
. simpleCrSprings
|
||||
. zoneCreatures
|
||||
. updateDoors
|
||||
. resetWorldEvents
|
||||
. dbArg _worldEvents
|
||||
. updateModifications
|
||||
. updateParticles
|
||||
. updateProjectiles
|
||||
. updateLightSources
|
||||
. updateClouds
|
||||
. zoneClouds
|
||||
. updateMachines
|
||||
. updateCreatures
|
||||
. updateCreatureGroups
|
||||
. updateBlocks
|
||||
. updateSeenWalls
|
||||
. (lSelHammerPosition %~ moveHammerUp)
|
||||
$ updateCloseObjects w
|
||||
where
|
||||
--updatedLightSources = mapMaybe (\b -> _tlsUpdate b w b) $ _tempLightSources w
|
||||
zoneCreatures = set (creaturesZone . znObjects)
|
||||
@@ -171,7 +178,7 @@ markWallSeen w wl = w { _walls = IM.adjust mw (_wlID wl) $ _walls w }
|
||||
|
||||
checkEndGame :: World -> World
|
||||
checkEndGame w
|
||||
| _crHP (you w) < 1 = haltSound $ w {_menuLayers = [gameOverMenu]}
|
||||
| _crHP (you w) < 1 = undefined -- haltSound $ w {_menuLayers = [gameOverMenu]}
|
||||
| otherwise = w
|
||||
|
||||
updateClouds :: World -> World
|
||||
|
||||
Reference in New Issue
Block a user