Allow multiple pulseBalls to be destroyed by one pulse laser shot
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
module Dodge.Item.Weapon.LaserPath (
|
||||
reflectLaserAlong,
|
||||
reflectPulseLaserAlong,
|
||||
) where
|
||||
|
||||
import Dodge.Data.Object
|
||||
import Data.Maybe
|
||||
import Data.Bifunctor
|
||||
import Data.Tuple
|
||||
import Dodge.Base.Wall
|
||||
@@ -65,28 +65,30 @@ refract phasev x y wl p
|
||||
reflectInternal = 1 < abs (phasev * sin angleInc')
|
||||
reflectExternal = 1 < abs (sin angleInc / phasev)
|
||||
|
||||
reflectPulseLaserAlong :: Float -> Point2 -> Point2 -> World ->
|
||||
(Maybe (Point2, Object), [Point2])
|
||||
-- note can hit multiple pulse balls
|
||||
reflectPulseLaserAlong :: Float -> Point2 -> Point2 -> World -> ([(Point2,Object)],[Point2])
|
||||
{-# INLINE reflectPulseLaserAlong #-}
|
||||
reflectPulseLaserAlong phasev sp ep w = case listToMaybe . filter (isunshad . snd) $ crWlPbHit sp ep w of
|
||||
Just (p, OWall wl)
|
||||
| _wlReflect wl ->
|
||||
second (p :) $
|
||||
reflectPulseLaserAlong
|
||||
phasev
|
||||
(p +.+ unitVectorAtAngle (reflDirWall sp p wl))
|
||||
(p +.+ dist p ep *.* unitVectorAtAngle (reflDirWall sp p wl))
|
||||
w
|
||||
| wlIsSeeThrough wl ->
|
||||
second (p :) $
|
||||
reflectPulseLaserAlong
|
||||
phasev
|
||||
(p +.+ normalizeV (refract phasev sp ep wl p))
|
||||
(refract phasev sp ep wl p)
|
||||
w
|
||||
| otherwise -> (Just (p, OWall wl), [p])
|
||||
Just (p, obj) -> (Just (p, obj), [p])
|
||||
Nothing -> (Nothing, [ep])
|
||||
reflectPulseLaserAlong phasev sp ep w = f $ filter (isunshad . snd) $ crWlPbHit sp ep w
|
||||
where
|
||||
f = \case
|
||||
((p, OWall wl) : _)
|
||||
| _wlReflect wl ->
|
||||
second (p :) $
|
||||
reflectPulseLaserAlong
|
||||
phasev
|
||||
(p +.+ unitVectorAtAngle (reflDirWall sp p wl))
|
||||
(p +.+ dist p ep *.* unitVectorAtAngle (reflDirWall sp p wl))
|
||||
w
|
||||
| wlIsSeeThrough wl ->
|
||||
second (p :) $
|
||||
reflectPulseLaserAlong
|
||||
phasev
|
||||
(p +.+ normalizeV (refract phasev sp ep wl p))
|
||||
(refract phasev sp ep wl p)
|
||||
w
|
||||
| otherwise -> ([(p, OWall wl)], [p])
|
||||
(x@(_,OPulseBall _) : ps ) -> first (x:) $ f ps
|
||||
((p, obj):_) -> ([(p, obj)], [p])
|
||||
[] -> ([], [ep])
|
||||
isunshad (OWall wl) = _wlUnshadowed wl
|
||||
isunshad _ = True
|
||||
|
||||
Reference in New Issue
Block a user