This commit is contained in:
2021-10-19 15:13:41 +01:00
parent 1f8b4b8565
commit 982c8d81e1
12 changed files with 22 additions and 62 deletions
+4 -6
View File
@@ -56,7 +56,7 @@ putDoor
putDoor col cond pss w = (drid, addWalls w & doors %~ addDoor)
where
drid = IM.newKey $ _doors w
addDoor = IM.insert drid $ Door'
addDoor = IM.insert drid $ Door
{ _drID = drid
, _drWallIDs = wlids
, _drStatus = DoorInt 0
@@ -77,7 +77,7 @@ putDoor col cond pss w = (drid, addWalls w & doors %~ addDoor)
}
-- TODO use vector instead of list, perhaps also memoisation of rectanglePairs
-- perhaps also remove use of DoorInt in favour of DoorOpen/DoorClosed
doorMechanismStepwise :: Int -> Int -> [Int] -> [(Point2,Point2)] -> Door' -> World -> World
doorMechanismStepwise :: Int -> Int -> [Int] -> [(Point2,Point2)] -> Door -> World -> World
doorMechanismStepwise nsteps drid wlids pss dr w
| toOpen = case _drStatus dr of
DoorInt x | x == nsteps -> w
@@ -99,9 +99,8 @@ doorMechanismStepwise nsteps drid wlids pss dr w
& (\w'' -> foldr (changeZonedWall (wlLine .~ ps) wlid) w'' (zoneps cps))
-- it is not at all clear that the zoning selects the correct walls
-- TODO think about wall zoning, simplify!
doorMechanism :: Int -> Float -> [(Int,(Point2,Point2),(Point2,Point2))] -> Door' -> World -> World
doorMechanism :: Int -> Float -> [(Int,(Point2,Point2),(Point2,Point2))] -> Door -> World -> World
doorMechanism drid speed wlidOpCps dr w
| toOpen && dstatus /= DoorOpen = moveUpdate $ foldl' doOpen w wlidOpCps
| not toOpen && dstatus /= DoorClosed = moveUpdate $ foldl' doClose w wlidOpCps
@@ -135,7 +134,7 @@ putSingleDoor isPathable col cond a b speed w = (drid, addWalls w
& doors %~ addDoor)
where
drid = IM.newKey $ _doors w
addDoor = IM.insert drid $ Door'
addDoor = IM.insert drid $ Door
{ _drID = drid
, _drWallIDs = wlids
, _drStatus = DoorClosed
@@ -155,4 +154,3 @@ putSingleDoor isPathable col cond a b speed w = (drid, addWalls w
shiftedPairs = map (bimap shiftLeft shiftLeft) pairs
shiftLeft = (+.+ (a -.- b))
wlids = take 4 [IM.newKey $ _walls w ..]