Files
loop/src/Dodge/Item/Weapon/Shatter.hs
T
2023-05-27 12:32:09 +01:00

39 lines
1.1 KiB
Haskell

module Dodge.Item.Weapon.Shatter where
import Dodge.Base.Collide
import Dodge.Block.Debris
import Dodge.Creature.HandPos
import Dodge.Data.World
import Dodge.Wall.Damage
import Geometry
import LensHelp
shootShatter :: Item -> Creature -> World -> World
shootShatter it cr w =
maybe w (uncurry $ shatterWall w sp ep) $
sequence $
collidePointWallsFilter canshatter sp ep w
where
canshatter wl = case _wlOpacity wl of
Opaque {} -> True
SeeThrough -> True
_ -> False
sp = _crPos cr +.+ aimingMuzzleLength cr it *.* unitVectorAtAngle dir
dir = _crDir cr
ep = sp +.+ 200 *.* unitVectorAtAngle dir
shatterWall :: World -> Point2 -> Point2 -> Point2 -> Wall -> World
shatterWall w sp ep p wl =
w
& makeDebris (_wlMaterial wl) (_wlColor wl) p
& makeDebrisDirected
1
2
(pi / 2)
(argV $ vNormal $ uncurry (-.-) $ _wlLine wl)
(_wlMaterial wl)
(_wlColor wl)
p
& damageWall (Damage SHATTERING 1000 sp p ep NoDamageEffect) wl