Simplify creature action/impulse code

This commit is contained in:
2025-10-18 17:32:23 +01:00
parent 11c7b25fe9
commit 4542a6cea6
4 changed files with 17 additions and 19 deletions
+1 -8
View File
@@ -1,11 +1,9 @@
--{-# LANGUAGE TupleSections #-}
module Dodge.Creature.Impulse (followImpulses) where
module Dodge.Creature.Impulse (followImpulse) where
import Control.Monad.State
import Data.Foldable
import Data.Maybe
import Dodge.Creature.Action
import Dodge.Creature.Impulse.Movement
import Dodge.Creature.MoveType
--import Dodge.Creature.Impulse.UseItem
@@ -21,11 +19,6 @@ import Linear
import NewInt
import System.Random
followImpulses :: Int -> World -> World
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) is
-- note SwitchToItem doesn't necessarily update the root item correctly
followImpulse :: Int -> World -> Impulse -> World
followImpulse cid w imp = case imp of