From ebc4b9d7156b07dfaee27c298e90ffba5d7104ce Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 18 Oct 2025 10:46:27 +0100 Subject: [PATCH] Simplify creature update --- src/Dodge/Creature/Update.hs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Dodge/Creature/Update.hs b/src/Dodge/Creature/Update.hs index 95ee11ebf..9f52531a3 100644 --- a/src/Dodge/Creature/Update.hs +++ b/src/Dodge/Creature/Update.hs @@ -43,12 +43,14 @@ updateCreature' cr = chasmTest cr . case _crType cr of Avatar{} -> (cWorld . lWorld . creatures . ix 0 . crType . avatarPulse %~ updatePulse) - . crUpdate yourControl cr + . crUpdate cid . yourControl cr LampCrit{} -> updateLampoid cr BarrelCrit bt -> updateBarreloid bt cr AvatarDead -> id - ChaseCrit {} -> crUpdate updateHumanoid cr - _ -> crUpdate updateHumanoid cr + ChaseCrit {} -> crUpdate cid . updateHumanoid cr + _ -> crUpdate cid . updateHumanoid cr + where + cid = cr ^. crID {- | this seems to work, but I am not sure about the ordering: previously, the movement was updated before the ai in order to correctly set the oldpos. @@ -57,16 +59,12 @@ updateCreature' cr = at what point invSideEffects is applied wrt to when the creature moves may affect whether the shield moves correctly -} -crUpdate :: (Creature -> World -> World) -> Creature -> World -> World -crUpdate f cr = +crUpdate :: Int -> World -> World +crUpdate cid = checkDeath cid . doDamage cid . invItemEffs cid - . g . updateWalkCycle cid - where - cid = cr ^. crID - g w' = maybe id f (w' ^? cWorld . lWorld . creatures . ix cid) w' checkDeath :: Int -> World -> World checkDeath cid w = maybe id checkDeath' (w ^? cWorld . lWorld . creatures . ix cid) w