Remove reified impulses from creature record

This commit is contained in:
2025-10-18 15:42:35 +01:00
parent b43168ae33
commit 4ee389efb1
16 changed files with 155 additions and 191 deletions
+5 -8
View File
@@ -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