Allow for door destruction

This commit is contained in:
2022-06-19 20:50:03 +01:00
parent 9e311cccf4
commit 08e5df07e2
14 changed files with 82 additions and 42 deletions
+9 -9
View File
@@ -5,6 +5,7 @@ module Dodge.Placement.PlaceSpot.TriggerDoor
) where
import Dodge.Data
import Dodge.Default.Wall
import Dodge.Default.Door
import Dodge.Wall.Move
import Dodge.LevelGen.DoorPane
import Picture
@@ -26,7 +27,7 @@ plDoor :: Color
plDoor col cond pss gw = (drid, addWalls gw & doors %~ addDoor)
where
drid = IM.newKey $ _doors gw
addDoor = IM.insert drid $ Door
addDoor = IM.insert drid $ defaultDoor
{ _drID = drid
, _drWallIDs = IS.fromList wlids
, _drStatus = DoorInt 0
@@ -39,16 +40,15 @@ plDoor col cond pss gw = (drid, addWalls gw & doors %~ addDoor)
nsteps = length pss - 1
wlids = take 4 [IM.newKey $ _walls gw ..]
wlps' = uncurry (rectanglePairs 9) $ head pss
addWalls w' = foldl' (addDoorWall col False) w' $ zip wlids wlps'
addWalls w' = foldl' (addDoorWall drid col False) w' $ zip wlids wlps'
addDoorWall :: Color -> Bool -> World -> (Int,(Point2,Point2)) -> World
addDoorWall col pathableStatus w (wlid,wlps) = w & walls %~ IM.insert wlid defaultWall
addDoorWall :: Int -> Color -> Bool -> World -> (Int,(Point2,Point2)) -> World
addDoorWall drid col pathableStatus w (wlid,wlps) = w & walls %~ IM.insert wlid defaultWall
{ _wlLine = wlps
, _wlID = wlid
, _wlColor = col
, _wlSeen = False
, _wlOpacity = Opaque
, _wlPathable = pathableStatus
, _wlStructure = DoorPart drid
}
-- TODO use vector instead of list, perhaps also memoisation of rectanglePairs
-- TODO update _drPos
@@ -108,10 +108,10 @@ plSlideDoor
-> World
-> (Int, World)
plSlideDoor isPathable col cond shiftOffset a b speed gw
= (drid, addWalls gw & doors %~ addDoor)
= (drid, addDoorWalls gw & doors %~ addDoor)
where
drid = IM.newKey $ _doors gw
addDoor = IM.insert drid $ Door
addDoor = IM.insert drid $ defaultDoor
{ _drID = drid
, _drWallIDs = IS.fromList wlids
, _drStatus = DoorClosed
@@ -121,7 +121,7 @@ plSlideDoor isPathable col cond shiftOffset a b speed gw
, _drOpenPos = (shiftLeft a,shiftLeft b)
, _drClosePos = (a,b)
}
addWalls w' = foldl' (addDoorWall col isPathable) w' $ zip wlids pairs
addDoorWalls w' = foldl' (addDoorWall drid col isPathable) w' $ zip wlids pairs
pairs = rectanglePairs 9 a b
shiftedPairs = map (bimap shiftLeft shiftLeft) pairs
shiftLeft = (+.+ (a -.- b +.+ shiftOffset *.* normalizeV (b -.- a)))