Further cleanup
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
module Dodge.Particle.Bullet.DestroyDamage
|
||||
( bulletDestroyDamage
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.WorldEvent.HitEffect
|
||||
import Dodge.Wall.Damage
|
||||
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
|
||||
@@ -1,72 +1,17 @@
|
||||
{- | Effects of bullets upon impact with walls or creatures. -}
|
||||
module Dodge.Particle.Bullet.HitEffect
|
||||
( basicBulDams
|
||||
, bounceBulDams
|
||||
, spawnBulDams
|
||||
, hvBulHitCr
|
||||
( hvBulHitCr
|
||||
, hvBulHitWall
|
||||
, bulletDestroySpawn
|
||||
, bulletDestroyDamage
|
||||
, bulBounceCr
|
||||
-- , bulBounceWall
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Particle.Spark
|
||||
import Dodge.Wall.Damage
|
||||
import Dodge.WorldEvent
|
||||
--import Dodge.WorldEvent.HitEffect
|
||||
import Dodge.RandomHelp
|
||||
import Dodge.Wall.Reflect
|
||||
import Geometry
|
||||
import Picture
|
||||
import LensHelp
|
||||
|
||||
import System.Random
|
||||
import Control.Monad.State
|
||||
|
||||
spawnBulDams :: (Particle -> Either Creature Wall -> Damage -> State StdGen Particle)
|
||||
-> Particle -> Point2 -> [Damage]
|
||||
spawnBulDams thespawn bt p =
|
||||
[ Damage Piercing 50 sp p ep (DamageSpawn $ thespawn bt)
|
||||
, Damage PushDam 1 sp p ep . PushBackDamage $ 2 *.* bulVel
|
||||
]
|
||||
where
|
||||
sp = head $ _ptTrail bt
|
||||
bulVel = _ptVel bt
|
||||
ep = sp +.+ bulVel
|
||||
|
||||
basicBulDams :: Particle -> Point2 -> [Damage]
|
||||
basicBulDams bt p =
|
||||
[ Damage Piercing 100 sp p ep NoDamageEffect
|
||||
, Damage PushDam 1 sp p ep . PushBackDamage $ 2 *.* bulVel
|
||||
]
|
||||
where
|
||||
sp = head $ _ptTrail bt
|
||||
bulVel = _ptVel bt
|
||||
ep = sp +.+ bulVel
|
||||
|
||||
bounceBulDams :: Particle -> Point2 -> [Damage]
|
||||
bounceBulDams bt p =
|
||||
[ Damage Piercing 80 sp p ep (BounceBullet bt)
|
||||
, Damage PushDam 1 sp p ep . PushBackDamage $ 2 *.* bulVel
|
||||
]
|
||||
where
|
||||
sp = head $ _ptTrail bt
|
||||
bulVel = _ptVel bt
|
||||
ep = sp +.+ bulVel
|
||||
|
||||
-- | Basic bullet hit creature effect.
|
||||
bulBounceCr :: Particle -> Point2 -> Creature -> World -> World
|
||||
bulBounceCr bt p cr = addDamage
|
||||
where
|
||||
sp = head $ _ptTrail bt
|
||||
bulVel = _ptVel bt
|
||||
ep = sp +.+ bulVel
|
||||
mvDams = [ Damage PushDam 1 sp p ep . PushBackDamage $ 2 *.* bulVel ]
|
||||
addDamage = creatures . ix cid . crState . crDamage .++~
|
||||
(Damage Piercing 100 sp p ep (BounceBullet bt) : mvDams)
|
||||
cid = _crID cr
|
||||
|
||||
{- | Heavy bullet effects when hitting creature:
|
||||
piercing, blunt, twisting and pushback damage all applied. -}
|
||||
hvBulHitCr :: Particle -> Point2 -> Creature -> World -> World
|
||||
@@ -87,62 +32,24 @@ damageGamut pdam bdam tor sp p ep =
|
||||
,Damage PushDam 1 sp p ep . PushBackDamage $ 3 *.* (ep -.- sp)
|
||||
]
|
||||
|
||||
bulletDestroySpawn :: (Point2 -> State StdGen Particle)
|
||||
-> Particle
|
||||
-> [(Point2, Either Creature Wall)]
|
||||
-> World
|
||||
-> (World, Maybe Particle)
|
||||
bulletDestroySpawn f = destroyOnImpact (bulDestroyCr f) (bulDestroyWall f)
|
||||
|
||||
bulletDestroyDamage :: (Particle -> Point2 -> [Damage])
|
||||
-> Particle
|
||||
-> [(Point2, Either Creature Wall)]
|
||||
-> World
|
||||
-> (World, Maybe Particle)
|
||||
bulletDestroyDamage fdm bt hitThings w = case hitThings of
|
||||
[] -> (w, mvPt bt)
|
||||
((p,Left cr):_) -> (creff cr p w, destroyAt p bt)
|
||||
((p,Right wl):_) -> (wleff wl p, destroyAt p bt)
|
||||
where
|
||||
creff cr p = addDamage
|
||||
where
|
||||
dams = fdm bt p
|
||||
addDamage = creatures . ix cid . crState . crDamage .++~ dams
|
||||
cid = _crID cr
|
||||
wleff wl p = foldr (\d -> damageWall d wl) w dams
|
||||
where
|
||||
dams = fdm bt p
|
||||
|
||||
{- | Create a particle when hitting a creature. -}
|
||||
bulDestroyCr :: (Point2 -> State StdGen Particle)
|
||||
-> Particle -> Point2 -> Creature -> World -> World
|
||||
bulDestroyCr f bt p cr w = w
|
||||
& instantParticles .:~ (pt & ptPos .~ p)
|
||||
& creatures . ix cid . crState . crDamage .:~ Damage Piercing 60 sp p ep NoDamageEffect
|
||||
& randGen .~ g
|
||||
where
|
||||
(pt,g) = randInCirc 1 >>= f & runState $ _randGen w
|
||||
cid = _crID cr
|
||||
sp = head $ _ptTrail bt
|
||||
ep = sp +.+ _ptVel bt
|
||||
|
||||
bulDestroyWall :: (Point2 -> State StdGen Particle)
|
||||
-> Particle
|
||||
-> Point2 -- Impact point
|
||||
-> Wall
|
||||
-> World
|
||||
-> World
|
||||
bulDestroyWall f bt p wl w = w
|
||||
& damageWall (Damage Piercing 60 sp p ep NoDamageEffect) wl
|
||||
& (instantParticles .:~ (pt & ptPos .~ pOut))
|
||||
& randGen .~ g
|
||||
where
|
||||
(pt,g) = runState (f reflectVel) (_randGen w)
|
||||
ep = sp +.+ _ptVel bt
|
||||
sp = head $ _ptTrail bt
|
||||
pOut = p +.+ squashNormalizeV (sp -.- p)
|
||||
wallV = uncurry (-.-) (_wlLine wl)
|
||||
reflectVel = squashNormalizeV $ reflectIn wallV (_ptVel bt)
|
||||
--bulletDestroyDamage :: (Particle -> Point2 -> [Damage])
|
||||
-- -> Particle
|
||||
-- -> [(Point2, Either Creature Wall)]
|
||||
-- -> World
|
||||
-- -> (World, Maybe Particle)
|
||||
--bulletDestroyDamage fdm bt hitThings w = case hitThings of
|
||||
-- [] -> (w, mvPt bt)
|
||||
-- ((p,Left cr):_) -> (creff cr p w, destroyAt p bt)
|
||||
-- ((p,Right wl):_) -> (wleff wl p, destroyAt p bt)
|
||||
-- where
|
||||
-- creff cr p = addDamage
|
||||
-- where
|
||||
-- dams = fdm bt p
|
||||
-- addDamage = creatures . ix cid . crState . crDamage .++~ dams
|
||||
-- cid = _crID cr
|
||||
-- wleff wl p = foldr (`damageWall` wl) w dams
|
||||
-- where
|
||||
-- dams = fdm bt p
|
||||
|
||||
hvBulHitWall
|
||||
:: Particle
|
||||
|
||||
@@ -3,12 +3,13 @@ module Dodge.Particle.Spark
|
||||
, colSparkRandDir
|
||||
, createBarrelSpark
|
||||
, randColDirTimeSpark
|
||||
)
|
||||
where
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Particle.HitEffect.ExpireAndDamage
|
||||
import Dodge.Particle.Bullet.Draw
|
||||
import Dodge.Particle.Damage
|
||||
--import Dodge.Particle.Bullet.HitEffect
|
||||
import Dodge.Particle.Bullet.Update
|
||||
import Dodge.Particle.Bullet.DestroyDamage
|
||||
--import Dodge.WorldEvent.HitEffect
|
||||
import Color
|
||||
import Geometry
|
||||
@@ -29,7 +30,7 @@ createBarrelSpark pos dir maycid time colid = instantParticles .:~ BulletPt
|
||||
, _ptCrIgnore = maycid
|
||||
, _ptWidth = 1
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = bulletDestroyDamage SparkDam 1
|
||||
, _ptHitEff = expireAndDamage basicSparkDams
|
||||
}
|
||||
colSpark :: Int -> Color -> Point2 -> Float -> World -> World
|
||||
colSpark = colSparkRandDir 0.7
|
||||
@@ -60,7 +61,7 @@ randColDirTimeSpark randcol randdir randtime pos w = w
|
||||
, _ptCrIgnore = Nothing
|
||||
, _ptWidth = 1
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = bulletDestroyDamage SparkDam 1
|
||||
, _ptHitEff = expireAndDamage basicSparkDams
|
||||
}
|
||||
|
||||
colSparkRandDir :: Float -> Int -> Color -> Point2 -> Float -> World -> World
|
||||
@@ -80,5 +81,5 @@ colSparkRandDir randDir time col pos baseDir w = w
|
||||
, _ptCrIgnore = Nothing
|
||||
, _ptWidth = 1
|
||||
, _ptTimer = time
|
||||
, _ptHitEff = bulletDestroyDamage SparkDam 1
|
||||
, _ptHitEff = expireAndDamage basicSparkDams
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user