Cancel terminal display if destroyed while displaying
This commit is contained in:
@@ -7,6 +7,7 @@ module Dodge.WorldEffect (
|
||||
lineOutputTerminal,
|
||||
) where
|
||||
|
||||
import Control.Monad
|
||||
import Data.Foldable
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
@@ -53,9 +54,12 @@ doWdWd we = case we of
|
||||
return $ heldEffectMuzzles loc cr w
|
||||
|
||||
accessTerminal :: Int -> World -> World
|
||||
accessTerminal tid =
|
||||
(hud . hudElement . subInventory .~ DisplayTerminal tid)
|
||||
. (cWorld . lWorld . terminals . ix tid %~ tryToBoot)
|
||||
accessTerminal tid w = fromMaybe w $ do
|
||||
tm <- w ^? cWorld . lWorld . terminals . ix tid
|
||||
guard (tm ^. tmStatus /= TerminalDeactivated)
|
||||
return $
|
||||
w & hud . hudElement . subInventory .~ DisplayTerminal tid
|
||||
& cWorld . lWorld . terminals . ix tid %~ tryToBoot
|
||||
where
|
||||
tryToBoot tm = case _tmStatus tm of
|
||||
TerminalTextInput{} -> tm
|
||||
@@ -84,7 +88,8 @@ lineOutputTerminal tls =
|
||||
}
|
||||
|
||||
doDeathTriggers :: Terminal -> World -> World
|
||||
doDeathTriggers tm = cWorld . lWorld . triggers %~ flip (foldl' $ flip doDeathToggle) xs
|
||||
doDeathTriggers tm = (cWorld . lWorld . triggers %~ flip (foldl' $ flip doDeathToggle) xs)
|
||||
. (cWorld . lWorld . terminals . ix (tm ^. tmID) . tmStatus .~ TerminalDeactivated)
|
||||
where
|
||||
xs = M.elems $ _tmToggles tm
|
||||
|
||||
|
||||
Reference in New Issue
Block a user