This commit is contained in:
2022-03-25 14:04:42 +00:00
parent 1607879014
commit e98ecfffb3
5 changed files with 168 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
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)