Simplify creature update
This commit is contained in:
@@ -43,12 +43,14 @@ updateCreature' cr =
|
|||||||
chasmTest cr . case _crType cr of
|
chasmTest cr . case _crType cr of
|
||||||
Avatar{} ->
|
Avatar{} ->
|
||||||
(cWorld . lWorld . creatures . ix 0 . crType . avatarPulse %~ updatePulse)
|
(cWorld . lWorld . creatures . ix 0 . crType . avatarPulse %~ updatePulse)
|
||||||
. crUpdate yourControl cr
|
. crUpdate cid . yourControl cr
|
||||||
LampCrit{} -> updateLampoid cr
|
LampCrit{} -> updateLampoid cr
|
||||||
BarrelCrit bt -> updateBarreloid bt cr
|
BarrelCrit bt -> updateBarreloid bt cr
|
||||||
AvatarDead -> id
|
AvatarDead -> id
|
||||||
ChaseCrit {} -> crUpdate updateHumanoid cr
|
ChaseCrit {} -> crUpdate cid . updateHumanoid cr
|
||||||
_ -> crUpdate updateHumanoid cr
|
_ -> crUpdate cid . updateHumanoid cr
|
||||||
|
where
|
||||||
|
cid = cr ^. crID
|
||||||
|
|
||||||
{- | this seems to work, but I am not sure about the ordering:
|
{- | 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.
|
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
|
at what point invSideEffects is applied wrt to when the creature moves
|
||||||
may affect whether the shield moves correctly
|
may affect whether the shield moves correctly
|
||||||
-}
|
-}
|
||||||
crUpdate :: (Creature -> World -> World) -> Creature -> World -> World
|
crUpdate :: Int -> World -> World
|
||||||
crUpdate f cr =
|
crUpdate cid =
|
||||||
checkDeath cid
|
checkDeath cid
|
||||||
. doDamage cid
|
. doDamage cid
|
||||||
. invItemEffs cid
|
. invItemEffs cid
|
||||||
. g
|
|
||||||
. updateWalkCycle cid
|
. updateWalkCycle cid
|
||||||
where
|
|
||||||
cid = cr ^. crID
|
|
||||||
g w' = maybe id f (w' ^? cWorld . lWorld . creatures . ix cid) w'
|
|
||||||
|
|
||||||
checkDeath :: Int -> World -> World
|
checkDeath :: Int -> World -> World
|
||||||
checkDeath cid w = maybe id checkDeath' (w ^? cWorld . lWorld . creatures . ix cid) w
|
checkDeath cid w = maybe id checkDeath' (w ^? cWorld . lWorld . creatures . ix cid) w
|
||||||
|
|||||||
Reference in New Issue
Block a user