Zoning/streaming refactor

This commit is contained in:
2022-06-26 00:26:53 +01:00
parent 3c7ea4d73b
commit e2d09d57e9
11 changed files with 67 additions and 55 deletions
+12 -6
View File
@@ -12,8 +12,9 @@ import Geometry
import Picture
import LensHelp
import Data.Foldable
--import Data.Foldable
import qualified Data.IntMap.Strict as IM
import qualified Streaming.Prelude as S
-- currently very effective against walls
makeShockwaveAt
:: [Int] -- ^ IDs of invulnerable creatures.
@@ -52,7 +53,7 @@ mvShockwave
:: [Int] -- ^ IDs of invulnerable creatures.
-> World -> Particle -> (World, Maybe Particle)
mvShockwave is w pt
| _ptTimer pt <= 0 = ( w , Nothing)
| _ptTimer pt <= 0 = ( w , Nothing)
| otherwise = (doDams w , Just $ pt & ptTimer -~ 1)
where
r = _ptRad pt
@@ -62,10 +63,15 @@ mvShockwave is w pt
t = _ptTimer pt
tFraction = fromIntegral t / fromIntegral (_ptMaxTime pt)
rad = r - (3/4) * r * tFraction
doDams = over creatures (IM.map damCr)
. flip (foldl' (flip $ damageWall (Damage EXPLOSIVE 10000 p p p NoDamageEffect)))
hitBlocks
hitBlocks = wallsOnCirc' p rad $ wallsNearPoint' p w
doDams w' = over creatures (IM.map damCr)
. runIdentity
$ S.fold_
(flip $ damageWall (Damage EXPLOSIVE 10000 p p p NoDamageEffect))
w'
id
hitBlocks
hitBlocks = S.map snd . overlapCircWalls p rad $ wallsAlongCirc' p rad w
-- this is not expansive enough
damCr cr
| _crID cr `elem` is || dist (_crPos cr) p >= rad + _crRad cr = cr
| otherwise = cr & crState . csDamage .:~