Add individual terminal offline updates
This commit is contained in:
@@ -20,6 +20,7 @@ import Sound.Data
|
||||
import Geometry
|
||||
import LensHelp
|
||||
|
||||
import qualified Data.Text as T
|
||||
--import System.Random
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
@@ -72,6 +73,7 @@ functionalUpdate cfig w = checkEndGame
|
||||
. updateGusts
|
||||
. zoneClouds
|
||||
. updateMIM magnets _mgUpdate
|
||||
. updateIMl' _terminals tmUpdate
|
||||
. updateIMl _machines mcChooseUpdate
|
||||
. updateIMl _creatures _crUpdate
|
||||
-- creatures should be updated early so that crOldPos is set before any position change
|
||||
@@ -97,6 +99,25 @@ mcChooseUpdate mc mc'
|
||||
. deleteWallIDs (_mcWallIDs mc)
|
||||
. _mcDeath mc mc'
|
||||
|
||||
tmUpdate :: Terminal -> World -> World
|
||||
tmUpdate tm w = case w ^? terminals . ix (_tmID tm) . tmFutureLines . ix 0 of
|
||||
Nothing -> w
|
||||
Just tl | _tlPause tl > 0 -> w & pointTermParams . tmFutureLines . ix 0 . tlPause -~ 1
|
||||
Just (TerminalLineDisplay _ f) -> w & pointTermParams %~
|
||||
( ( tmFutureLines %~ tail )
|
||||
. ( tmDisplayedLines .:~ f w )
|
||||
)
|
||||
Just (TerminalLineEffect _ eff) -> w
|
||||
& pointTermParams . tmFutureLines %~ tail
|
||||
& eff (_subInventory . _hudElement $ _hud w)
|
||||
Just (TerminalLineInput _) -> w & pointTermParams %~
|
||||
( ( tmFutureLines %~ tail )
|
||||
-- . ( tmScrollCommands .~ scrollc )
|
||||
-- . ( tmWriteCommands .~ writec )
|
||||
. ( tmInput ?~ T.empty ) )
|
||||
where
|
||||
pointTermParams = terminals . ix (_tmID tm)
|
||||
|
||||
setOldPos :: Creature -> Creature
|
||||
setOldPos cr = cr
|
||||
& crOldPos .~ _crPos cr
|
||||
@@ -137,6 +158,9 @@ updateCreatureSoundPositions w = M.foldrWithKey insertSound w
|
||||
updateIMl :: (World -> IM.IntMap a) -> (a -> a -> World -> World) -> World -> World
|
||||
updateIMl fim fup w = foldl' (flip $ dbArg fup) w (fim w)
|
||||
|
||||
updateIMl' :: (World -> IM.IntMap a) -> (a -> World -> World) -> World -> World
|
||||
updateIMl' fim fup w = foldl' (flip fup) w (fim w)
|
||||
|
||||
updateBlocks :: World -> World
|
||||
updateBlocks w = foldr f w $ _blocks w
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user