Abstract and unify door mechanisms
This commit is contained in:
@@ -97,16 +97,7 @@ autoDoorPane (trigx,trigy) n closedPos openPos = Door
|
||||
, _drPositions = DS.singleton closedPos
|
||||
}
|
||||
where
|
||||
a = fst closedPos
|
||||
b = snd closedPos
|
||||
dm w
|
||||
| any (crNearSeg 40 trigx trigy) $ IM.filter isAnimate $ _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
|
||||
dm = doorMechan n (zoneps closedPos) openDoor closeDoor cond
|
||||
cond = any (crNearSeg 40 trigx trigy) . IM.filter isAnimate . _creatures
|
||||
openDoor = moveDoorToward openPos
|
||||
closeDoor = moveDoorToward closedPos
|
||||
zoneps | dist a b <= 2 * zoneSize = [zoneOfPoint $ pHalf a b]
|
||||
| otherwise = map zoneOfPoint $ divideLine (2*zoneSize) a b
|
||||
changeZonedWall (!x,!y) = over wallsZone $ adjustIMZone openDoor x y n
|
||||
changeZonedWall' (!x,!y) = over wallsZone $ adjustIMZone closeDoor x y n
|
||||
|
||||
Reference in New Issue
Block a user