module Dodge.Creature.Update ( updateCreature, ) where import Control.Lens import Dodge.Creature.YourControl import Dodge.Creature.State import Dodge.Barreloid import Dodge.Data.World import Dodge.Humanoid import Dodge.Lampoid updateCreature :: Creature -> World -> World updateCreature cr = case _crType cr of Avatar{} -> (cWorld . lWorld . creatures . ix 0 . crType . avatarPulse %~ updatePulse) . crUpdate yourControl cr Lampoid{} -> updateLampoid cr Humanoid{} -> updateHumanoid cr Barreloid{} -> updateBarreloid cr NonDrawnCreature -> id updatePulse :: Pulse -> Pulse updatePulse PulseStatus {_pulseRate = pr, _pulseProgress = pp} | pp >= pr = PulseStatus pr 0 | otherwise = PulseStatus pr (pp + 1)