Refactor, try to limit dependencies

This commit is contained in:
2022-07-28 00:59:56 +01:00
parent 8aa5c17ab9
commit 160560af5f
418 changed files with 15104 additions and 13342 deletions
+36 -30
View File
@@ -1,14 +1,14 @@
module Dodge.Barreloid where
import Dodge.Data
import Dodge.WorldEvent.Explosion
import Dodge.Spark
import Dodge.Creature.State
import Geometry
import Dodge.SoundLogic
import LensHelp
import System.Random
import Data.List
import Dodge.Creature.State
import Dodge.Data.World
import Dodge.SoundLogic
import Dodge.Spark
import Dodge.WorldEvent.Explosion
import Geometry
import LensHelp
import System.Random
updateBarreloid :: Creature -> World -> World
updateBarreloid cr = case cr ^?! crType . barrelType of
@@ -17,46 +17,52 @@ updateBarreloid cr = case cr ^?! crType . barrelType of
-- should generate the sparks externally using new random generators
updateExpBarrel :: Creature -> World -> World
updateExpBarrel cr w
updateExpBarrel cr w
| _crHP cr > 0 = foldr ($) (hiss w & cWorld . creatures . at (_crID cr) .~ newCr) pierceSparks
| otherwise = makeExplosionAt (_crPos cr) $ stopSounds w & cWorld . creatures . at (_crID cr) .~ Nothing
where
| otherwise = makeExplosionAt (_crPos cr) $ stopSounds w & cWorld . creatures . at (_crID cr) .~ Nothing
where
g = _randGen w
damages = _csDamage $ _crState cr
pierceSparks :: [World -> World]
pierceSparks
= zipWith3 (\p a -> createBarrelSpark (_crPos cr +.+ p) (a + argV p))
poss as colids
as = randomRs (-0.7,0.7) g
colids = randomRs (0,11) g
pierceSparks =
zipWith3
(\p a -> createBarrelSpark (_crPos cr +.+ p) (a + argV p))
poss
as
colids
as = randomRs (-0.7, 0.7) g
colids = randomRs (0, 11) g
poss = _piercedPoints $ _csSpState $ _crState cr
newCr = Just $ applyFuseDamage $ set (crState . csDamage) [] $ damToExpBarrel damages cr
applyFuseDamage cr' = cr' & crHP %~
subtract (length . _piercedPoints . _csSpState $ _crState cr')
hiss | null poss = id
| otherwise = soundMultiFrom [BarrelHiss 0,BarrelHiss 1] (_crPos cr) foamSprayLoopS (Just 1)
applyFuseDamage cr' =
cr' & crHP
%~ subtract (length . _piercedPoints . _csSpState $ _crState cr')
hiss
| null poss = id
| otherwise = soundMultiFrom [BarrelHiss 0, BarrelHiss 1] (_crPos cr) foamSprayLoopS (Just 1)
stopSounds = stopSoundFrom (BarrelHiss 0) . stopSoundFrom (BarrelHiss 1)
updateBarrel :: Creature -> World -> World
updateBarrel cr
| _crHP cr > 0 = doDamage cr
| otherwise = cWorld . creatures . at (_crID cr) .~ Nothing
| otherwise = cWorld . creatures . at (_crID cr) .~ Nothing
damToExpBarrel :: [Damage] -> Creature -> Creature
damToExpBarrel ds cr = foldr damToExpBarrel' (foldr damToExpBarrel' cr pierceDam) otherDam
where
(pierceDam,otherDam) = partition isPierce ds
where
(pierceDam, otherDam) = partition isPierce ds
isPierce Damage{_dmType = PIERCING{}} = True
isPierce _ = False
isPierce _ = False
damToExpBarrel' :: Damage -> Creature -> Creature
damToExpBarrel' dm cr = case _dmType dm of
PIERCING -> over (crState . csSpState . piercedPoints) ((:) $ int -.- _crPos cr)
$ cr & crHP -~ div amount 200
POISONDAM -> cr
SPARKING -> cr
-- PUSHDAM -> cr LensHelp.& crPos .+.+~ (1 / _crMass cr *.* _dePushBack (_dmEffect dm))
_ -> cr LensHelp.& crHP -~ amount
PIERCING ->
over (crState . csSpState . piercedPoints) ((:) $ int -.- _crPos cr) $
cr & crHP -~ div amount 200
POISONDAM -> cr
SPARKING -> cr
-- PUSHDAM -> cr LensHelp.& crPos .+.+~ (1 / _crMass cr *.* _dePushBack (_dmEffect dm))
_ -> cr LensHelp.& crHP -~ amount
where
amount = _dmAmount dm
int = _dmAt dm