Implementation of creature update using endofunctor monoid
This commit is contained in:
@@ -63,7 +63,7 @@ polyToTriFold _ = []
|
||||
initialiseLamp :: Float -> CRUpdate
|
||||
initialiseLamp h w (f,g) cr = ( (addLS . f , g), Just $ cr & crUpdate .~ updateLamp h i)
|
||||
where
|
||||
i = IM.newKey $ _lightSources $ f w -- to give different lights different keys
|
||||
i = _crID cr
|
||||
addLS = over lightSources (IM.insert i (lightAt (V3 x y h) i))
|
||||
(V2 x y) = _crPos cr
|
||||
|
||||
|
||||
@@ -30,9 +30,11 @@ import Control.Monad.State
|
||||
import System.Random
|
||||
--import qualified Data.Set as S
|
||||
--import qualified Data.Map as M
|
||||
|
||||
import Data.Monoid
|
||||
|
||||
type CRUpdate = World -> (World -> World,StdGen) -> Creature -> ((World -> World,StdGen), Maybe Creature)
|
||||
|
||||
|
||||
meleeCooldown :: CRUpdate -> CRUpdate
|
||||
meleeCooldown u w (f,g) cr = u w (f,g) $ cr & crMeleeCooldown . _Just %~ (max 0 . (\x -> x - 1))
|
||||
-- | The movement is updated before the ai in order to correctly set the oldpos.
|
||||
|
||||
Reference in New Issue
Block a user