Add file, fix lamp doDamage space leak

This commit is contained in:
2021-05-12 20:48:55 +02:00
parent ead87af3c1
commit 9b3fbba393
13 changed files with 165 additions and 226 deletions
+15 -1
View File
@@ -28,6 +28,7 @@ lamp = defaultInanimate
, _crHP = 100
, _crPict = \ _ -> onLayer CrLayer $ color white $ circleSolid 3
, _crRad = 3
, _crMass = 3
}
initialiseLamp :: CRUpdate
@@ -37,7 +38,20 @@ 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 = unrandUpdate handleLS internalUpdate
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
where
handleLS cr w
| _crHP cr < 0 = explosionFlashAt cPos