Remove Reader from chaseCrit

This commit is contained in:
2021-12-11 19:07:14 +00:00
parent e698695842
commit ab7a503515
3 changed files with 33 additions and 34 deletions
+20 -20
View File
@@ -3,7 +3,6 @@ module Dodge.Creature.ReaderUpdate
( doStrategyActionsR
, doStrategyActions
, setTargetMv
, setTargetMv'
, targetYouWhenCognizantR
, targetYouWhenCognizant
, overrideMeleeCloseTargetR
@@ -19,7 +18,9 @@ module Dodge.Creature.ReaderUpdate
, flockACCR
, flockACC
, setMvPos
, setMvPos'
, setViewPos
, setViewPos'
)
where
import Dodge.Data
@@ -62,33 +63,32 @@ setMvPos cr = pure $ cr & crIntention . mvToPoint .~ mpos
mpos = (_crPos <$> _targetCr int)
<|> _mvToPoint int
-- <|> listToMaybe (_soundsToInvestigate $ _crMemory cr)
--
setMvPos' :: Creature -> Creature
setMvPos' cr = cr & crIntention . mvToPoint .~ mpos
where
int = _crIntention cr
mpos = (_crPos <$> _targetCr int)
<|> _mvToPoint int
-- <|> listToMaybe (_soundsToInvestigate $ _crMemory cr)
setViewPos :: Creature -> Reader World Creature
setViewPos cr = pure $ cr & crIntention . viewPoint %~ (<|> mpos)
where
mpos = listToMaybe (_soundsToInvestigate $ _crMemory cr)
setTargetMv
:: (Creature -> Reader World (Maybe Creature)) -- ^ Function for determining target
-> Creature
-> Reader World Creature
setTargetMv targFunc cr = do
targ <- targFunc cr
case targ of
Nothing -> pure cr
Just crTarg -> pure $ cr & crIntention . mvToPoint ?~ _crPos crTarg
setViewPos' :: Creature -> Creature
setViewPos' cr = cr & crIntention . viewPoint %~ (<|> mpos)
where
mpos = listToMaybe (_soundsToInvestigate $ _crMemory cr)
setTargetMv'
:: (World -> Creature -> Maybe Creature) -- ^ Function for determining target
-> World
-> Creature
-> Creature
setTargetMv' targFunc w cr = maybe cr (\ctarg -> cr & crIntention . mvToPoint ?~ _crPos ctarg)
setTargetMv :: (World -> Creature -> Maybe Creature) -- ^ Function for determining target
-> World -> Creature -> Creature
setTargetMv targFunc w cr = maybe
cr
(\ctarg -> cr & crIntention . mvToPoint ?~ _crPos ctarg)
(targFunc w cr)
-- targ <- targFunc cr
-- case targ of
-- Nothing -> pure cr
-- Just crTarg -> pure $ cr & crIntention . mvToPoint ?~ _crPos crTarg
flockACCR :: Creature -> Reader World Creature
flockACCR cr = do
case cr ^? crIntention . targetCr . _Just of