Remove reified impulses from creature record
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
--{-# LANGUAGE TupleSections #-}
|
||||
|
||||
module Dodge.Creature.Impulse (followImpulses) where
|
||||
|
||||
import Dodge.Creature.Action
|
||||
import Data.Maybe
|
||||
import NewInt
|
||||
import Linear
|
||||
@@ -20,14 +21,10 @@ import Geometry
|
||||
import LensHelp
|
||||
import System.Random
|
||||
|
||||
--followImpulses :: World -> Creature -> (World -> World, Creature)
|
||||
--followImpulses w cr = foldl' (flip f) (id, cr) (reverse $ _apImpulse $ _crActionPlan cr)
|
||||
-- where
|
||||
-- f imp (theupdate, cr') = first (. theupdate) $ followImpulse cr' w imp
|
||||
|
||||
followImpulses :: Int -> World -> World
|
||||
followImpulses cid w = foldl' (followImpulse cid) w
|
||||
(reverse $ w ^?! cWorld . lWorld . creatures . ix cid . crActionPlan . apImpulse)
|
||||
followImpulses cid w = let (is,cr) = performActions w (w ^?! cWorld . lWorld . creatures . ix cid)
|
||||
in foldl' (followImpulse cid) (w & cWorld . lWorld . creatures . ix cid .~ cr)
|
||||
(reverse is)
|
||||
|
||||
-- note SwitchToItem doesn't necessarily update the root item correctly
|
||||
followImpulse :: Int -> World -> Impulse -> World
|
||||
|
||||
Reference in New Issue
Block a user