Refactor launcherCrit ai

This commit is contained in:
2021-05-13 14:23:58 +02:00
parent 9b3fbba393
commit 2402e1e868
10 changed files with 133 additions and 233 deletions
+1 -15
View File
@@ -38,20 +38,7 @@ initialiseLamp w (f,g) cr = ( (addLS . f , g), Just $ cr & crUpdate .~ updateLam
addLS = over lightSources (IM.insert i (lightAt (_crPos cr) i))
updateLamp :: Int -> CRUpdate
updateLamp i w (f,g) cr = ((handleLS . f, g), internalUpdate)
where
handleLS w'
| _crHP cr < 0 = explosionFlashAt cPos
$ mkSoundBreakGlass cPos w' & lightSources %~ IM.delete i
| otherwise = w' & lightSources . ix i . lsPos .~ cPos
where
cPos = _crPos cr
internalUpdate
| _crHP cr < 0 = Nothing
| otherwise = fmap doDamage $ Just cr
updateLamp' :: Int -> CRUpdate
updateLamp' i = unrandUpdate handleLS internalUpdate
updateLamp i = unrandUpdate handleLS internalUpdate
where
handleLS cr w
| _crHP cr < 0 = explosionFlashAt cPos
@@ -63,7 +50,6 @@ updateLamp' i = unrandUpdate handleLS internalUpdate
| _crHP cr < 0 = Nothing
| otherwise = Just $ doDamage cr
barrel :: Creature
barrel = defaultInanimate
{ _crUpdate = updateBarrel