Implement pulse rifle with explodable pulse balls
This commit is contained in:
@@ -11,8 +11,10 @@ module Dodge.WorldEvent.ThingsHit (
|
||||
crsHitRadial,
|
||||
wlsHitRadial,
|
||||
crHit,
|
||||
crWlPbHit,
|
||||
) where
|
||||
|
||||
import Dodge.Data.Object
|
||||
import Dodge.Creature.Radius
|
||||
import Control.Monad
|
||||
import Control.Lens
|
||||
@@ -26,6 +28,7 @@ import Dodge.Zoning.Creature
|
||||
import Dodge.Zoning.Wall
|
||||
import Geometry
|
||||
import qualified ListHelp as List
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
|
||||
{- List those objects that appear on a line. -}
|
||||
thingsHit :: Point2 -> Point2 -> World -> [(Point2, Either Creature Wall)]
|
||||
@@ -35,6 +38,16 @@ thingsHit sp ep w =
|
||||
(map (second Left) (crsHit sp ep w))
|
||||
(map (second Right) (wlsHit sp ep w))
|
||||
|
||||
crWlPbHit :: Point2 -> Point2 -> World -> [(Point2, Object)]
|
||||
crWlPbHit sp ep w =
|
||||
List.mergeOn
|
||||
(dist sp . fst)
|
||||
(map (fmap toobj) (thingsHit sp ep w))
|
||||
(map (fmap OPulseBall) (pbsHit sp ep w))
|
||||
where
|
||||
toobj (Left cr) = OCreature cr
|
||||
toobj (Right wl) = OWall wl
|
||||
|
||||
crsHit :: Point2 -> Point2 -> World -> [(Point2, Creature)]
|
||||
crsHit sp ep w
|
||||
| sp == ep = mempty
|
||||
@@ -46,6 +59,15 @@ crsHit sp ep w
|
||||
. crixsNearSeg sp ep
|
||||
$ w
|
||||
|
||||
pbsHit :: Point2 -> Point2 -> World -> [(Point2, PulseBall)]
|
||||
pbsHit sp ep w
|
||||
| sp == ep = mempty
|
||||
| otherwise =
|
||||
sortOn (dist sp . fst)
|
||||
. mapMaybe (\pb -> (,pb) <$> listToMaybe (intersectCircSeg (_pbPos pb) 8 sp ep))
|
||||
. IM.elems
|
||||
$ w ^. cWorld . lWorld . pulseBalls
|
||||
|
||||
thingHitFilt ::
|
||||
(Creature -> Bool) ->
|
||||
(Wall -> Bool) ->
|
||||
|
||||
Reference in New Issue
Block a user