Add concept of GameRoom, check viewing distance based on rooms
This commit is contained in:
@@ -11,6 +11,7 @@ import FoldableHelp
|
||||
import Data.Maybe
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
import qualified FoldlHelp as L
|
||||
|
||||
hasLOS :: Point2 -> Point2 -> World -> Bool
|
||||
{-# INLINE hasLOS #-}
|
||||
@@ -71,12 +72,36 @@ furthestPointWalkable p1 p2 ws
|
||||
. safeMinimumOn (dist p1)
|
||||
$ IM.mapMaybe ( uncurry (intersectSegSeg p1 p2) . _wlLine) ws
|
||||
|
||||
collideDirectionIndirect
|
||||
:: Float -- ^max distance to look
|
||||
-> Point2 -- ^start point
|
||||
-> Point2 -- ^point in direction
|
||||
-> IM.IntMap Wall
|
||||
-> Float
|
||||
{-# INLINE collideDirectionIndirect #-}
|
||||
collideDirectionIndirect d p1 p2 wls
|
||||
= fromMaybe d
|
||||
$
|
||||
( L.fold
|
||||
. L.prefilter (not . _wlIsSeeThrough)
|
||||
. L.premapMaybe (fmap (dist p1) . uncurry (intersectSegSeg p1 p3) . _wlLine)
|
||||
) L.minimum
|
||||
wls
|
||||
where
|
||||
p3 = p1 +.+ d *.* safeNormalizeV (p2 -.- p1)
|
||||
|
||||
collidePointIndirect :: Point2 -> Point2 -> IM.IntMap Wall -> Maybe Point2
|
||||
{-# INLINE collidePointIndirect #-}
|
||||
collidePointIndirect p1 p2
|
||||
= safeMinimumOn (dist p1)
|
||||
. IM.mapMaybe ( uncurry (intersectSegSeg p1 p2) . _wlLine)
|
||||
. IM.filter (not . _wlIsSeeThrough)
|
||||
collidePointIndirect p1 p2
|
||||
= L.fold
|
||||
. L.prefilter (not . _wlIsSeeThrough)
|
||||
. L.premapMaybe (uncurry (intersectSegSeg p1 p2) . _wlLine)
|
||||
$ L.minimumOn (dist p1)
|
||||
--collidePointIndirect p1 p2
|
||||
-- = safeMinimumOn (dist p1)
|
||||
-- . IM.mapMaybe ( uncurry (intersectSegSeg p1 p2) . _wlLine)
|
||||
-- . IM.filter (not . _wlIsSeeThrough)
|
||||
|
||||
{- | Checks to see whether someone can fire bullets effectively between two points.
|
||||
- Not sure if this needs vision as well, need to make this uniform. -}
|
||||
collidePointFire :: Point2 -> Point2 -> IM.IntMap Wall -> Maybe Point2
|
||||
|
||||
Reference in New Issue
Block a user