Improve door crushing
This commit is contained in:
@@ -34,6 +34,7 @@ module Dodge.Base.Collide (
|
||||
collide3,
|
||||
) where
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import qualified Data.IntSet as IS
|
||||
@@ -48,7 +49,7 @@ import FoldableHelp
|
||||
import Geometry
|
||||
import Linear
|
||||
|
||||
collidePoint :: Point2 -> Point2 -> [Wall] -> (Point2, Maybe Wall)
|
||||
collidePoint :: Foldable t => Point2 -> Point2 -> t Wall -> (Point2, Maybe Wall)
|
||||
{-# INLINE collidePoint #-}
|
||||
collidePoint sp ep = foldl' f (ep, Nothing)
|
||||
where
|
||||
@@ -201,7 +202,7 @@ collidePointTestFilter t sp ep =
|
||||
|
||||
collidePointWallsFilter :: (Wall -> Bool) -> Point2 -> Point2 -> World -> (Point2, Maybe Wall)
|
||||
{-# INLINE collidePointWallsFilter #-}
|
||||
collidePointWallsFilter t sp ep = collidePoint sp ep . filter t . wlsNearSeg sp ep
|
||||
collidePointWallsFilter t sp ep = collidePoint sp ep . IM.filter t . wlsNearSeg sp ep
|
||||
|
||||
-- overlapSegWalls :: Point2 -> Point2 -> StreamOf Wall
|
||||
-- -> StreamOf (Point2,Wall)
|
||||
@@ -219,6 +220,7 @@ visibleWalls sp ep =
|
||||
takeUntil (wlIsOpaque . snd)
|
||||
. sortOn (dist sp . fst)
|
||||
. overlapSegWalls sp ep
|
||||
. IM.elems
|
||||
. wlsNearSeg sp ep
|
||||
|
||||
allVisibleWalls :: World -> [(Point2, Wall)]
|
||||
@@ -296,6 +298,7 @@ hasLOS :: Point2 -> Point2 -> World -> Bool
|
||||
hasLOS p1 p2 =
|
||||
not
|
||||
. collidePointTestFilter (const True) p1 p2
|
||||
. IM.elems
|
||||
. wlsNearSeg p1 p2
|
||||
|
||||
hasButtonLOS :: Point2 -> Point2 -> World -> Bool
|
||||
@@ -312,6 +315,7 @@ hasLOSIndirect :: Point2 -> Point2 -> World -> Bool
|
||||
hasLOSIndirect p1 p2 =
|
||||
not
|
||||
. collidePointTestFilter wlIsOpaque p1 p2
|
||||
. IM.elems
|
||||
. wlsNearSeg p1 p2
|
||||
|
||||
canSee :: Int -> Int -> World -> Bool
|
||||
|
||||
Reference in New Issue
Block a user