Refactor wall points from lists to pairs
This commit is contained in:
@@ -45,13 +45,13 @@ mkAutoDoor pl pr xs = addSound $ zipWith3 (autoDoorPane (pl,pr))
|
||||
(lDoorClosed ++ rDoorClosed)
|
||||
(map shiftL lDoorClosed ++ map shiftR rDoorClosed)
|
||||
where
|
||||
lDoorClosed = [ [pld,hwd]
|
||||
, [hwd,hwu]
|
||||
, [hwu,plu]
|
||||
lDoorClosed = [ (pld,hwd)
|
||||
, (hwd,hwu)
|
||||
, (hwu,plu)
|
||||
]
|
||||
rDoorClosed = [ [pru,hwu]
|
||||
, [hwu,hwd]
|
||||
, [hwd,prd]
|
||||
rDoorClosed = [ (pru,hwu)
|
||||
, (hwu,hwd)
|
||||
, (hwd,prd)
|
||||
]
|
||||
norm = 10 *.* errorNormalizeV 49 ( vNormal (pr -.- pl))
|
||||
hw = 0.5 *.* (pl +.+ pr)
|
||||
@@ -62,21 +62,23 @@ mkAutoDoor pl pr xs = addSound $ zipWith3 (autoDoorPane (pl,pr))
|
||||
prd = pr -.- norm
|
||||
hwu = hw +.+ norm
|
||||
hwd = hw -.- norm
|
||||
shiftL = map $ (+.+ parallel) . (-.- normalizeV parallel)
|
||||
shiftR = map $ (-.- parallel) . (+.+ normalizeV parallel)
|
||||
shiftL = h $ (+.+ parallel) . (-.- normalizeV parallel)
|
||||
shiftR = h $ (-.- parallel) . (+.+ normalizeV parallel)
|
||||
h func (x,y) = (func x,func y)
|
||||
|
||||
addSound (x:xs) = f x : xs
|
||||
f wl = over doorMech g wl
|
||||
g dm w | dist wp pld > 2 && dist wp hwd > 2
|
||||
= soundFrom (WallSound (head xs)) (fromIntegral doorSound) 1 0 $ dm w
|
||||
| otherwise = dm w
|
||||
where wp = (_wlLine $ _walls w IM.! (head xs)) !! 1
|
||||
where
|
||||
wp = snd (_wlLine $ _walls w IM.! (head xs))
|
||||
|
||||
autoDoorPane
|
||||
:: (Point2,Point2) -- ^ Trigger line
|
||||
-> Int -- ^ Wall id
|
||||
-> [Point2] -- ^ Closed position
|
||||
-> [Point2] -- ^ Open position
|
||||
-> (Point2,Point2) -- ^ Closed position
|
||||
-> (Point2,Point2) -- ^ Open position
|
||||
-> Wall
|
||||
autoDoorPane (trigx,trigy) n closedPos openPos = Door
|
||||
{ _wlLine = closedPos
|
||||
@@ -89,17 +91,17 @@ autoDoorPane (trigx,trigy) n closedPos openPos = Door
|
||||
, _drPositions = DS.singleton closedPos
|
||||
}
|
||||
where
|
||||
a = closedPos !! 0
|
||||
b = closedPos !! 1
|
||||
a = fst closedPos
|
||||
b = snd closedPos
|
||||
dm w
|
||||
| any (crNearSeg 40 trigx trigy) $ IM.filter (_crIsAnimate . _crState) $ _creatures w
|
||||
= flip (foldr changeZonedWall) zoneps $ over walls (IM.adjust openDoor n) w
|
||||
| otherwise
|
||||
= flip (foldr changeZonedWall') zoneps $ over walls (IM.adjust closeDoor n) w
|
||||
mvP !ep !p = mvPointTowardAtSpeed 2 ep p
|
||||
moveToward :: [Point2] -> Wall -> Wall
|
||||
moveToward !ps w = let !newPs = zipWith mvP ps $ _wlLine w
|
||||
in deepseq newPs $ w {_wlLine = newPs}
|
||||
mvPs (ex,ey) (sx,sy) = (mvP ex sx,mvP ey sy)
|
||||
moveToward :: (Point2,Point2) -> Wall -> Wall
|
||||
moveToward (ex,ey) wls = wls & wlLine %~ mvPs (ex,ey)
|
||||
openDoor = moveToward openPos
|
||||
closeDoor = moveToward closedPos
|
||||
zoneps | dist a b <= 2 * zoneSize = [zoneOfPoint $ pHalf a b]
|
||||
|
||||
Reference in New Issue
Block a user