This commit is contained in:
2022-07-19 19:02:37 +01:00
parent 34c1ffd803
commit b4c0074d43
3 changed files with 10 additions and 44 deletions
@@ -1,29 +0,0 @@
module Dodge.Particle.HitEffect.ExpireAndDamage where
import Dodge.Data
import Dodge.Particle.Update
--import Dodge.Wall.Damage
import Geometry
import LensHelp
import qualified Data.IntMap.Strict as IM
import Streaming
import qualified Streaming.Prelude as S
expireAndDamage :: (Particle -> Point2 -> [Damage])
-> Particle
-> Stream (Of (Point2, Either Creature Wall)) Identity ()
-> World
-> (World, Maybe Particle)
expireAndDamage fdm bt things w = case runIdentity $ S.head_ things of
Nothing -> (w, mvPt' bt)
Just x -> (doDamages fdm x bt w, destroyAt bt)
doDamages :: (Particle -> Point2 -> [Damage])
-> (Point2, Either Creature Wall)
-> Particle
-> World
-> World
doDamages fdm (p,thhit) bt = case thhit of
Left cr -> creatures . ix (_crID cr) . crState . csDamage .++~ dams
Right wl -> wallDamages %~ IM.insertWith (++) (_wlID wl) dams
where
dams = fdm bt p
-5
View File
@@ -6,11 +6,6 @@ mvPt' :: Particle -> Maybe Particle
mvPt' pt = Just $ pt
& ptTimer -~ 1
destroyAt :: Particle -> Maybe Particle
destroyAt pt = Just $ pt
& ptUpdate .~ killParticleUpdate
& ptTimer %~ (min 3 . subtract 1)
killParticleUpdate :: World -> Particle -> (World,Maybe Particle)
killParticleUpdate w pt
| _ptTimer pt <= 0 = (w,Nothing)