Fix bugs in zoning

This commit is contained in:
2022-07-30 14:21:13 +01:00
parent c8ad3e1294
commit 82db86f55f
16 changed files with 204 additions and 157 deletions
+11 -13
View File
@@ -7,12 +7,12 @@ module Dodge.Spark (
randSpark,
) where
import Dodge.Damage
import Color
import Control.Monad.State
import Dodge.Data.World
import Dodge.WorldEvent.ThingsHit
import Geometry
import qualified IntMapHelp as IM
import LensHelp
import System.Random
@@ -37,8 +37,7 @@ sparkDam ::
World ->
World
sparkDam sk sp ep mayEiCrWl = case mayEiCrWl of
(hitp, Left cr) -> cWorld . creatures . ix (_crID cr) . crState . csDamage .:~ thedam hitp
(hitp, Right wl) -> cWorld . wallDamages %~ IM.insertWith (++) (_wlID wl) [thedam hitp]
(hitp, eicrwl) -> damageCrWl (thedam hitp) eicrwl
where
thedam hitp = Damage (_skDamageType sk) 1 sp hitp ep NoDamageEffect
@@ -56,22 +55,21 @@ randColDirSpark ::
World
randColDirSpark randcol randdir pos w =
w
& cWorld . sparks .:~ spark
& randGen .~ g
& cWorld . sparks
.:~ Spark
{ _skVel = rotateV dir (V2 5 0)
, _skColor = col
, _skPos = pos
, _skOldPos = pos
, _skWidth = 1
, _skDamageType = SPARKING
}
where
((col, dir), g) = (`runState` _randGen w) $ do
c <- randcol
d <- randdir
return (c, d)
spark =
Spark
{ _skVel = rotateV dir (V2 5 0)
, _skColor = col
, _skPos = pos
, _skOldPos = pos
, _skWidth = 1
, _skDamageType = SPARKING
}
randSpark ::
DamageType ->