Add file
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
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
|
||||
|
||||
-- TODO cleanup wrt destroyOnImpact etc
|
||||
bulletDestroyDamage :: DamageType
|
||||
-> Int -- | damage amount
|
||||
-> Particle
|
||||
-> [(Point2, Either Creature Wall)]
|
||||
-> World
|
||||
-> (World, Maybe Particle)
|
||||
bulletDestroyDamage dt amount = destroyOnImpact (bulDamageCr dt amount)
|
||||
(bulDamageWall dt amount)
|
||||
|
||||
{- | Create a particle when hitting a creature. -}
|
||||
bulDamageCr :: DamageType -> Int
|
||||
-> Particle -> Point2 -> Creature -> World -> World
|
||||
bulDamageCr dt amount bt p cr w = w
|
||||
& bulletHitSound' p
|
||||
& 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
|
||||
|
||||
-- this is a duplicate! anyway, sound should be made by the hit creature
|
||||
bulletHitSound' :: Point2 -> World -> World
|
||||
bulletHitSound' p = soundMultiFrom [CrHitSound 0] p hit1S (Just 10)
|
||||
Reference in New Issue
Block a user