Work on sensor machines, remove some datatypes associated with placements

This commit is contained in:
2021-11-01 23:07:58 +00:00
parent 82de39657b
commit 7ef1da9be5
16 changed files with 265 additions and 220 deletions
-26
View File
@@ -1,26 +0,0 @@
--{-# LANGUAGE BangPatterns #-}
{- |
Creation of doors that open when creatures approach them.
-}
module Dodge.LevelGen.AutoDoor
where
import Dodge.Data
import Dodge.Base
import Dodge.Creature.Property
--import Dodge.LevelGen.MoveDoor
import Dodge.LevelGen.TriggerDoor
--import Geometry
import Picture
import Geometry.Data
--import qualified DoubleStack as DS
import qualified IntMapHelp as IM
addAutoDoor
:: Point2 -- ^ Left point
-> Point2 -- ^ Right point (though the two points should be symmetric)
-> World
-> World
addAutoDoor a b = insertDoubleDoor True (dim yellow) cond a b 3
where
cond = any (crNearSeg 40 a b) . IM.filter isAnimate . _creatures
+1 -2
View File
@@ -17,11 +17,10 @@ data PSType = PutCrit {_unPutCrit :: Creature}
| PutProp Prop
| PutFlIt Item
| PutPressPlate PressPlate
| PutAutoDoor Point2 Point2
-- | PutAutoDoor Point2 Point2
| PutBlock [Int] Color [Point2]
| PutLineBlock Wall Float Float Point2 Point2
| PutWall { _pwPoly :: [Point2] , _pwWall :: Wall }
| PutDoubleDoor Color (World -> Bool) Point2 Point2 Float
| PutSingleDoor Color (World -> Bool) Point2 Point2 Float
| PutDoor Color (World -> Bool) [(Point2,Point2)]
| PutBtDoor Color Point2 Float Point2 Point2 Float
+4 -11
View File
@@ -1,9 +1,8 @@
--{-# LANGUAGE BangPatterns #-}
module Dodge.LevelGen.TriggerDoor
( putDoor
, putSingleDoor
, placeSingleDoor
, addButtonDoor
, insertDoubleDoor
) where
import Dodge.Data
import Dodge.Base
@@ -34,7 +33,7 @@ addButtonDoor c btp btr a b speed w
$ set pathPoints (foldr insertPoint IM.empty (labNodes newGraph))
$ set pathGraph newGraph
$ set pathGraphP newGraphPairs
$ snd (putSingleDoor False c cond a b speed w)
$ snd (placeSingleDoor False c cond a b speed w)
where
bid = IM.newKey $ _buttons w
cond w' = BtNoLabel == _btState (_buttons w' IM.! bid)
@@ -123,15 +122,9 @@ doorMechanism drid speed wlidOpCps dr w
& walls . ix wlid %~ moveDoorToward speed p
& (\w'' -> foldr (changeZonedWall (moveDoorToward speed p) wlid) w'' (zoneps zp))
insertDoubleDoor :: Bool -> Color -> (World -> Bool) -> Point2 -> Point2 -> Float -> World
-> World
insertDoubleDoor isPathable col cond a b speed
= snd . putSingleDoor isPathable col cond a (0.5 *.* (a +.+ b)) speed
. snd . putSingleDoor isPathable col cond b (0.5 *.* (a +.+ b)) speed
putSingleDoor :: Bool -> Color -> (World -> Bool) -> Point2 -> Point2 -> Float -> World
placeSingleDoor :: Bool -> Color -> (World -> Bool) -> Point2 -> Point2 -> Float -> World
-> (Int, World)
putSingleDoor isPathable col cond a b speed w = (drid, addWalls w
placeSingleDoor isPathable col cond a b speed w = (drid, addWalls w
& doors %~ addDoor)
where
drid = IM.newKey $ _doors w