Refactor doors

This commit is contained in:
2022-07-24 20:36:27 +01:00
parent 2c1bc67a51
commit d6a94ec4bc
25 changed files with 186 additions and 135 deletions
+10
View File
@@ -1,12 +1,22 @@
module Dodge.WorldBool
where
import Dodge.CreatureEffect
import Dodge.Creature.Test
import Dodge.Data
import Data.Maybe
import Control.Lens
import qualified IntMapHelp as IM
doWdBl :: WdBl -> World -> Bool
doWdBl wb w = case wb of
WdBlConst bl -> bl
WdTrig i -> fromMaybe False $ w ^? triggers . ix i
WdBlDoorMoving i -> fromMaybe False $ do
dr <- w ^? doors . ix i
return (DoorHalfway == _drStatus dr)
WdBlCrFilterNearPoint r p t -> any (crNearPoint r p) (IM.filter (doCrBl t) (_creatures w))
WdBlBtOn btid -> _btState (_buttons w IM.! btid) == BtOn -- unsafe
WdBlBtNotOff btid -> _btState (_buttons w IM.! btid) /= BtOff -- unsafe
WdBlNegate x -> not $ doWdBl x w