Improve static bullets
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
--{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{- |
|
||||
Find which objects lie upon a line.
|
||||
-}
|
||||
@@ -7,6 +7,8 @@ module Dodge.WorldEvent.ThingsHit
|
||||
, thingHit
|
||||
, thingHitFilt
|
||||
, thingsHitExceptCr
|
||||
, crsHitRadial
|
||||
, wlsHitRadial
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
@@ -15,6 +17,7 @@ import Dodge.Zone
|
||||
import Geometry
|
||||
|
||||
--import Data.Maybe
|
||||
import Data.Functor
|
||||
import Data.Bifunctor
|
||||
import StreamingHelp
|
||||
import qualified Streaming.Prelude as S
|
||||
@@ -66,3 +69,19 @@ wlsHit sp ep
|
||||
| otherwise = sortStreamOn (dist sp . fst)
|
||||
. overlapSegWalls sp ep
|
||||
. wlsNearSeg sp ep
|
||||
|
||||
wlsHitRadial :: Point2 -> Float -> World -> StreamOf (Point2, Wall)
|
||||
wlsHitRadial p r = S.mapMaybe f . wlsInsideCirc p r
|
||||
where
|
||||
f wl = uncurry (intersectSegSeg p (p -.- r *.* v)) (_wlLine wl) <&> (,wl)
|
||||
where
|
||||
v = normalizeV $ vNormal $ uncurry (-.-) $ _wlLine wl
|
||||
|
||||
crsHitRadial :: Point2 -> Float -> World -> StreamOf (Point2, Creature)
|
||||
crsHitRadial p r = S.mapMaybe f . crsInsideCirc p r
|
||||
where
|
||||
f cr
|
||||
| dist cpos p <= r = Just (cpos +.+ r *.* normalizeV (p -.- cpos), cr)
|
||||
| otherwise = Nothing
|
||||
where
|
||||
cpos = _crPos cr
|
||||
|
||||
Reference in New Issue
Block a user