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
+9 -10
View File
@@ -9,17 +9,15 @@ import Dodge.Default.Door
import Color
import Geometry
import Dodge.LevelGen.Data
import Dodge.Creature.Test
import Dodge.LevelGen.Switch
import Control.Lens
import qualified IntMapHelp as IM
putDoubleDoor :: EdgeObstacle -> Wall -> (World -> Bool) -> Point2 -> Point2 -> Float -> Placement
putDoubleDoor :: EdgeObstacle -> Wall -> WdBl -> Point2 -> Point2 -> Float -> Placement
putDoubleDoor eo wl cond a b speed
= putDoubleDoorThen eo wl cond 1 a b speed (const $ const Nothing)
putDoubleDoorThen ::EdgeObstacle -> Wall -> (World -> Bool)
putDoubleDoorThen ::EdgeObstacle -> Wall -> WdBl
-> Float -> Point2 -> Point2 -> Float
-> (Placement -> Placement -> Maybe Placement)
-> Placement
@@ -30,7 +28,7 @@ putDoubleDoorThen eo wl cond soff a b speed cont
where
half = 0.5 *.* (a +.+ b)
doorBetween :: EdgeObstacle -> Wall -> (World -> Bool) -> Float -> Point2 -> Point2 -> Float ->
doorBetween :: EdgeObstacle -> Wall -> WdBl -> Float -> Point2 -> Point2 -> Float ->
(Placement -> Maybe Placement) -> Placement
doorBetween eo wl cond soff pa pb speed g = case divideLine 40 pa pb of
[x,y] -> ptCont (PutSlideDr adoor wl eo soff x y) g
@@ -41,7 +39,7 @@ doorBetween eo wl cond soff pa pb speed g = case divideLine 40 pa pb of
& drTrigger .~ cond
& drSpeed .~ speed
divideDoorPane :: Maybe Int -> Wall -> (World -> Bool) -> Float -> Float
divideDoorPane :: Maybe Int -> Wall -> WdBl -> Float -> Float
-> [(Point2,Point2)] -> (Placement -> Maybe Placement) -> Placement
divideDoorPane mid wl cond soff speed ppairs g = case ppairs of
[p] -> ptCont (adoor p) g
@@ -59,8 +57,9 @@ putAutoDoor a b = PlacementUsingPos (addZ 0 a)
(cond az bz) a b 3
where
--cond az bz = any (crNearSeg 40 (stripZ az) (stripZ bz)) . IM.filter isAnimate . _creatures
cond az bz = any (crNearPoint 40 (0.5 *.* (stripZ az +.+ stripZ bz)))
. IM.filter isAnimate . _creatures
cond az bz = WdBlCrFilterNearPoint 40 (0.5 *.* (stripZ az +.+ stripZ bz)) CrIsAnimate
-- any (crNearPoint 40 (0.5 *.* (stripZ az +.+ stripZ bz)))
-- . IM.filter isAnimate . _creatures
switchDoor :: Point2 -> Float -> Point2 -> Point2 -> Color -> Placement
switchDoor btpos btrot dra drb col = pContID (PS btpos btrot)
@@ -71,7 +70,7 @@ switchDoor btpos btrot dra drb col = pContID (PS btpos btrot)
doorbetween btid a b = PutSlideDr thedoor (switchWallCol col) DoorObstacle 1 a b
where
thedoor = defaultDoor
& drTrigger .~ cond btid
& drTrigger .~ WdBlBtOn btid
& drSpeed .~ 2
drc = 0.5 *.* (dra +.+ drb)
cond btid w' = _btState (_buttons w' IM.! btid) == BtOn
--cond btid w' = _btState (_buttons w' IM.! btid) == BtOn