Make creature update an external function
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user