Files
loop/src/Dodge/Particle/HitEffect.hs
T
2022-03-25 14:04:42 +00:00

25 lines
803 B
Haskell

module Dodge.Particle.HitEffect
( penWalls
) where
import Dodge.Data
import Dodge.Particle.Update
import Geometry
import Data.Bifunctor
type HitCreatureEffect = Particle -> Point2 -> Creature -> World -> World
type HitWallEffect = Particle -> Point2 -> Wall -> World -> World
penWalls
:: HitCreatureEffect
-> HitWallEffect
-> Particle
-> [(Point2, Either Creature Wall)]
-> World
-> (World, Maybe Particle)
penWalls crEff wlEff pt hitThings w = case hitThings of
[] -> ( w, mvPt pt)
((p,Left cr):_) -> (crEff pt p cr w, destroyAt p pt)
((p,Right wl):hs) | _wlFireThrough wl
-> first (wlEff pt p wl) $ penWalls crEff wlEff pt hs w
((p,Right wl):_) -> (wlEff pt p wl w, destroyAt p pt)