Simplify creature action/impulse code
This commit is contained in:
@@ -11,6 +11,7 @@ module Dodge.Creature.Action (
|
||||
youDropItem,
|
||||
) where
|
||||
|
||||
import Data.Foldable
|
||||
import Linear
|
||||
import NewInt
|
||||
import Dodge.Creature.MoveType
|
||||
@@ -32,11 +33,20 @@ import Dodge.SoundLogic
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import Dodge.Creature.Impulse
|
||||
|
||||
performActions :: World -> Creature -> ([Impulse],Creature)
|
||||
performActions w cr = (concat iss
|
||||
, cr & crActionPlan . apAction .~ catMaybes mayas)
|
||||
--performActions :: World -> Creature -> ([Impulse],Creature)
|
||||
--performActions w cr = (concat iss
|
||||
-- , cr & crActionPlan . apAction .~ catMaybes mayas)
|
||||
-- where
|
||||
-- (iss, mayas) = unzip $ map (performAction cr w) $ cr ^. crActionPlan . apAction
|
||||
|
||||
performActions :: Int -> World -> World
|
||||
performActions cid w = foldl' (followImpulse cid)
|
||||
(w & cWorld . lWorld . creatures . ix cid . crActionPlan . apAction .~ catMaybes mayas)
|
||||
(concat iss)
|
||||
where
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||
(iss, mayas) = unzip $ map (performAction cr w) $ cr ^. crActionPlan . apAction
|
||||
|
||||
type OutAction = ([Impulse], Maybe Action)
|
||||
|
||||
Reference in New Issue
Block a user