Files
loop/src/Dodge/Particle/Bullet/DestroyDamage.hs
T

42 lines
1.1 KiB
Haskell

module Dodge.Particle.Bullet.DestroyDamage
( bulletDestroyDamage
) where
import Dodge.Data
import Dodge.WorldEvent.HitEffect
import Dodge.Wall.Damage
import Dodge.SoundLogic
import Geometry
import LensHelp
bulletDestroyDamage :: DamageType
-> Int -- | damage amount
-> Particle
-> [(Point2, Either Creature Wall)]
-> World
-> (World, Maybe Particle)
bulletDestroyDamage dt amount = destroyOnImpact
(bulDamageCr dt amount)
(bulDamageWall dt amount)
bulDamageCr :: DamageType -> Int
-> Particle -> Point2 -> Creature -> World -> World
bulDamageCr dt amount bt p cr w = w
& creatures . ix cid . crState . crDamage .:~ Damage dt amount sp p ep NoDamageEffect
where
cid = _crID cr
sp = head $ _ptTrail bt
ep = sp +.+ _ptVel bt
bulDamageWall :: DamageType
-> Int
-> Particle
-> Point2 -- Impact point
-> Wall
-> World
-> World
bulDamageWall dt amount bt p wl w = w
& damageWall (Damage dt amount sp p ep NoDamageEffect) wl
where
ep = sp +.+ _ptVel bt
sp = head $ _ptTrail bt