Split off StreamingHelp module

This commit is contained in:
2022-06-28 12:26:37 +01:00
parent 0cb6657f35
commit e770fba7bf
7 changed files with 50 additions and 41 deletions
+6 -6
View File
@@ -25,6 +25,7 @@ import LensHelp
import Data.Foldable
import Data.Tuple
import StreamingHelp
import qualified Streaming.Prelude as S
aFlameParticle
:: Int -- ^ Timer
@@ -240,14 +241,13 @@ makeGasCloud pos vel w = w
(col, g) = runState (takeOne [green,yellow]) $ _randGen w
{- Attach poison cloud damage to creatures near cloud. -}
cloudPoisonDamage :: Cloud -> World -> World
cloudPoisonDamage c w = w & creatures
%~ dodamagesto damagedCrs
cloudPoisonDamage c w = w & dodamagesto (S.filter f $ crsNearPoint clpos w)
where
dodamagesto :: StreamOf Creature -> IM.IntMap Creature -> IM.IntMap Creature
dodamagesto = undefined
damagedCrs = S.filter f $ crsNearPoint clpos w
dodamagesto :: StreamOf Creature -> World -> World
dodamagesto scrs mcrs = runIdentity $ S.fold_ (flip doDam) mcrs id scrs
doDam cr = creatures . ix (_crID cr) . crState . csDamage
.:~ Damage POISONDAM 1 clpos clpos clpos NoDamageEffect
f cr = dist3 (addZ 20 $ _crPos cr) (_clPos c) < _crRad cr + _clRad c + 10
doDam cr = cr & crState . csDamage .:~ Damage POISONDAM 1 clpos clpos clpos NoDamageEffect
clpos = stripZ $ _clPos c
incBall :: RandomGen g => Point2 -> State g Particle