Various improvements, metal debris

This commit is contained in:
2022-06-23 18:53:26 +01:00
parent e3d5c4eb4b
commit 8d266a6770
18 changed files with 147 additions and 82 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ addBlock (p:ps) wl bl w = w
= insertIMInZone x y wlid wl'
| otherwise = flip (foldl' $ flip (\(a,b) -> insertIMInZone a b wlid wl')) ips
where
(x,y) = zoneOfPoint $ uncurry pHalf (_wlLine wl)
(x,y) = zoneOfPoint $ uncurry midPoint (_wlLine wl)
wlid = _wlID wl
ips = map zoneOfPoint $ uncurry (divideLine (2*zoneSize)) (_wlLine wl)
addBlock _ _ _ _ = error "Trying to add a block with incomplete polygon"
+8 -12
View File
@@ -5,7 +5,6 @@ module Dodge.Placement.PlaceSpot.TriggerDoor
) where
import Dodge.Data
import Dodge.Base
import Dodge.Default.Wall
import Dodge.Default.Door
import Dodge.Wall.Move
import Dodge.LevelGen.DoorPane
@@ -42,14 +41,12 @@ 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 drid col False) w' $ zip wlids wlps'
addWalls w' = foldl' (addDoorWall drid $ switchWallCol col) w' $ zip wlids wlps'
addDoorWall :: Int -> Color -> Bool -> World -> (Int,(Point2,Point2)) -> World
addDoorWall drid col pathableStatus w (wlid,wlps) = w & walls %~ IM.insert wlid defaultWall
addDoorWall :: Int -> Wall -> World -> (Int,(Point2,Point2)) -> World
addDoorWall drid wl w (wlid,wlps) = w & walls %~ IM.insert wlid wl
{ _wlLine = wlps
, _wlID = wlid
, _wlColor = col
, _wlPathable = pathableStatus
, _wlStructure = DoorPart drid
}
-- TODO use vector instead of list, perhaps also memoisation of rectanglePairs
@@ -80,7 +77,7 @@ doorMechanismStepwise nsteps drid wlids pss dr w
doorMechanism :: Door -> World -> World
doorMechanism dr w = case mvDir of
Just d -> w
& flip (IS.foldr (`translateWallID` d)) (_drWallIDs dr)
& flip (IS.foldl' (flip (`translateWallID` d))) (_drWallIDs dr)
& moveUpdate
& doors . ix drid . drPos . each %~ (+.+ d)
Nothing -> w
@@ -105,15 +102,14 @@ doorMechanism dr w = case mvDir of
-- TODO cut pathing if not pathable, reset when opened
plSlideDoor
:: Bool
-> Color
-> Door
:: Door
-> Wall
-> Float
-> Point2
-> Point2
-> World
-> (Int, World)
plSlideDoor isPathable col dr shiftOffset a b gw
plSlideDoor dr wl shiftOffset a b gw
= (drid, addDoorWalls gw & doors %~ addDoor)
where
drid = IM.newKey $ _doors gw
@@ -126,7 +122,7 @@ plSlideDoor isPathable col dr shiftOffset a b gw
, _drOpenPos = (shiftLeft a,shiftLeft b)
, _drClosePos = (a,b)
}
addDoorWalls w' = foldl' (addDoorWall drid col isPathable) w' $ zip wlids pairs
addDoorWalls w' = foldl' (addDoorWall drid wl) w' $ zip wlids pairs
pairs = rectanglePairs 9 a b
shiftLeft = (+.+ (a -.- b +.+ shiftOffset *.* normalizeV (b -.- a)))
wlids = take 4 [IM.newKey $ _walls gw ..]