Control wall damage effects using the wall

This commit is contained in:
2021-11-01 16:50:09 +00:00
parent 7ddbbdda14
commit e4c73b9b8b
7 changed files with 93 additions and 57 deletions
+11 -16
View File
@@ -6,7 +6,7 @@ module Dodge.Particle.Bullet.HitEffect
import Dodge.Data
import Dodge.Data.DamageType
import Dodge.Data.SoundOrigin
import Dodge.WorldEvent.DamageBlock
import Dodge.Wall.Damage
import Dodge.WorldEvent
import Dodge.Particle.Bullet.Spawn
import Dodge.SoundLogic
@@ -16,7 +16,7 @@ import Dodge.WorldEvent.Shockwave
import Dodge.Creature.State.Data
import Dodge.Creature.Property
import Geometry
import Geometry.Vector3D
--import Geometry.Vector3D
import Picture
import System.Random
@@ -132,24 +132,18 @@ bulConCr' bt p cr w
mkwave = over worldEvents $ (.) (makeShockwaveAt [] p 15 4 1 white)
{- | Hitting wall effects: create a spark, damage blocks. -}
bulHitWall :: Particle -> Point2 -> Wall -> World -> World
bulHitWall bt p wl w = damageBlocksBy 5 wl
. smokeCloudAt dustcol 20 200 1 (addZ 20 pOut)
$ colSpark' 0.2 8 theCol pOut (reflectDir wl)
w
bulHitWall bt p = damageWall (Piercing 100 sp p ep)
where
dustcol = _wlColor wl & _4 .~ 1
theCol = brightX 100 1.5 white
ep = sp +.+ _btVel' bt
sp = head $ _btTrail' bt
pOut = p +.+ safeNormalizeV (sp -.- p)
reflectDir wall = argV (reflectIn (uncurry (-.-) (_wlLine wall)) (p -.- sp) )
{- | Bounce off walls, do damage to blocks. -}
bulBounceWall' :: Particle -> Point2 -> Wall -> World -> World
bulBounceWall' bt p wl w = damageBlocksBy 5 wl $ over worldEvents addBouncer w
bulBounceWall :: Particle -> Point2 -> Wall -> World -> World
bulBounceWall bt p wl = damageWall (Blunt 50 sp p ep) wl . over worldEvents addBouncer
where
ep = sp +.+ _btVel' bt
sp = head $ _btTrail' bt
pOut = p +.+ safeNormalizeV (sp -.- p)
bouncer = (aGenBulAt Nothing pOut reflectVel
(_btHitEffect' bt) (_btWidth' bt)
bouncer = (aGenBulAt Nothing pOut reflectVel (_btHitEffect' bt) (_btWidth' bt)
) {_btTimer' = _btTimer' bt - 1}
wallV = uncurry (-.-) (_wlLine wl)
reflectVel = reflectIn wallV (_btVel' bt)
@@ -159,14 +153,15 @@ bulBounceWall' bt p wl w = damageBlocksBy 5 wl $ over worldEvents addBouncer w
-- this list
{- | Create flamelet on wall. -}
bulIncWall'
bulIncWall
:: Particle
-> Point2 -- Impact point
-> Wall
-> World
-> World
bulIncWall' bt p wl w = damageBlocksBy 5 wl $ incFlamelets w
bulIncWall bt p wl = damageWall (Blunt 50 sp p ep) wl . incFlamelets
where
ep = sp +.+ _btVel' bt
sp = head $ _btTrail' bt
pOut = p +.+ safeNormalizeV (sp -.- p)
wallV = uncurry (-.-) (_wlLine wl)