Improve machines, tweak wall ids

This commit is contained in:
2021-11-01 15:21:21 +00:00
parent 7692421112
commit 7ddbbdda14
11 changed files with 76 additions and 28 deletions
+12 -2
View File
@@ -17,6 +17,7 @@ import Dodge.Creature.Memory.Data
import Dodge.SoundLogic
import Dodge.SoundLogic.LoadSound
import Dodge.Picture.Layer
import Dodge.Wall.Delete
import Geometry
import Picture
import ShapePicture
@@ -212,14 +213,23 @@ defaultIt = Consumable
defaultMachine :: Machine
defaultMachine = Machine
{ _mcID = 0
, _mcWallIDs = []
, _mcUpdate = const id
, _mcWallIDs = mempty
, _mcUpdate = defaultMachineUpdate
, _mcDraw = const mempty
, _mcPos = V2 0 0
, _mcDir = 0
, _mcHP = 100
, _mcSensor = 0
, _mcDamage = []
}
defaultMachineUpdate :: Machine -> World -> World
defaultMachineUpdate mc w
| _mcHP mc < 1 = w & machines %~ IM.delete mcid
& deleteWallIDs (_mcWallIDs mc)
| otherwise = w & machines . ix mcid %~ ( (mcDamage .~ []) . (mcHP -~ dams) )
where
dams = sum $ map _dmAmount $ _mcDamage mc
mcid = _mcID mc
defaultDrawButton :: Color -> Button -> SPic
defaultDrawButton col bt =