Make creature update an external function

This commit is contained in:
2022-07-20 01:22:17 +01:00
parent db44d5d6ce
commit 1f79fe157f
31 changed files with 562 additions and 462 deletions
+29
View File
@@ -0,0 +1,29 @@
module Dodge.Lampoid where
import Dodge.Data
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
updateLampoid :: Creature -> World -> World
updateLampoid cr w = case cr ^?! crType . lampLSID of
Nothing -> let i = IM.newKey (_lightSources w)
in w & lightSources . at i ?~ lsColPosID lcol (addZ h cpos) i
Just i
| _crHP cr < 0 -> w
& explosionFlashAt cpos
& originsIDsAt [MaterialSound Glass n | n <- [0,1,2]] (destroyMatS Glass) cpos
& lightSources . at i .~ Nothing
& creatures . at cid .~ Nothing
| otherwise -> w
& lightSources . ix i . lsParam . lsPos .~ addZ h cpos
& doDamage cr
where
cpos = _crPos cr
cid = _crID cr
crtype = _crType cr
h = _lampHeight crtype
lcol = _lampColor crtype