Implement pulse rifle with explodable pulse balls

This commit is contained in:
2025-07-27 11:10:30 +01:00
parent 68a4bc7aab
commit f1fb0ee768
19 changed files with 190 additions and 108 deletions
+22
View File
@@ -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) ->