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
+22 -17
View File
@@ -1,30 +1,35 @@
module Dodge.Lampoid where
import Dodge.Data
import Dodge.Creature.State
import Dodge.Data.World
import Dodge.LightSource
import Dodge.Material.Sound
import Dodge.WorldEvent.Flash
import Dodge.WorldEvent.Sound
import Dodge.Creature.State
import Dodge.LightSource
import Geometry
import LensHelp
import qualified IntMapHelp as IM
import LensHelp
updateLampoid :: Creature -> World -> World
updateLampoid cr w = case cr ^?! crType . lampLSID of
Nothing -> let i = IM.newKey (_lightSources (_cWorld w))
in w & cWorld . lightSources %~ IM.insert i (lsColPosID lcol (addZ h cpos) i)
& cWorld . creatures . ix (_crID cr) . crType . lampLSID ?~ i
Just i
| _crHP cr < 0 -> w
& explosionFlashAt cpos
& originsIDsAt [MaterialSound Glass n | n <- [0,1,2]] (destroyMatS Glass) cpos
& cWorld . lightSources . at i .~ Nothing
& cWorld . creatures . at cid .~ Nothing
| otherwise -> w
& cWorld . lightSources . ix i . lsParam . lsPos .~ addZ h cpos
& doDamage cr
Nothing ->
let i = IM.newKey (_lightSources (_cWorld w))
in w & cWorld . lightSources %~ IM.insert i (lsColPosID lcol (addZ h cpos) i)
& cWorld . creatures . ix (_crID cr) . crType . lampLSID ?~ i
Just i
| _crHP cr < 0 ->
w
& explosionFlashAt cpos
& originsIDsAt [MaterialSound Glass n | n <- [0, 1, 2]] (destroyMatS Glass) cpos
& cWorld . lightSources . at i .~ Nothing
& cWorld . creatures . at cid .~ Nothing
| otherwise ->
w
& cWorld . lightSources . ix i . lsParam . lsPos .~ addZ h cpos
& doDamage cr
where
cpos = _crPos cr
cid = _crID cr
cid = _crID cr
crtype = _crType cr
h = _lampHeight crtype
lcol = _lampColor crtype