From 0b949dc51264cb4b94c6d6d7328c95ed40b41bd0 Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 6 Jun 2022 11:32:37 +0100 Subject: [PATCH] Add individual terminal offline updates --- src/Dodge/Update.hs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index e97a306f9..63ead4dd6 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -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