Remove Reader from chaseCrit
This commit is contained in:
@@ -16,7 +16,6 @@ import Picture
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
--import Control.Monad.Reader
|
||||
|
||||
armourChaseCrit :: Creature
|
||||
armourChaseCrit = defaultCreature
|
||||
@@ -25,7 +24,7 @@ armourChaseCrit = defaultCreature
|
||||
, Right doStrategyActions
|
||||
, Left performActions
|
||||
, Left targetYouWhenCognizant
|
||||
, Left $ setTargetMv' (\_ -> _targetCr . _crIntention)
|
||||
, Left $ setTargetMv (\_ -> _targetCr . _crIntention)
|
||||
, Left flockACC
|
||||
, Left $ perceptionUpdate' [0]
|
||||
, Left goToTarget'
|
||||
|
||||
@@ -5,6 +5,7 @@ module Dodge.Creature.ChaseCrit
|
||||
import Dodge.Data
|
||||
import Dodge.Default
|
||||
import Dodge.Creature.Picture
|
||||
import Dodge.Creature.ChainUpdates
|
||||
import Dodge.Creature.ReaderUpdate
|
||||
import Dodge.Creature.Impulse
|
||||
import Dodge.Creature.Action
|
||||
@@ -20,7 +21,6 @@ import Picture
|
||||
--import Data.Maybe
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
--import System.Random
|
||||
|
||||
smallChaseCrit :: Creature
|
||||
@@ -33,17 +33,17 @@ smallChaseCrit = chaseCrit
|
||||
}
|
||||
chaseCrit :: Creature
|
||||
chaseCrit = defaultCreature
|
||||
{ _crUpdate = stateUpdate $ --dummyUpdate
|
||||
impulsiveAIR $
|
||||
doStrategyActionsR >=>
|
||||
performActionsR >=>
|
||||
overrideMeleeCloseTargetR >=>
|
||||
setViewPos >=>
|
||||
setMvPos >=>
|
||||
goToTarget >=>
|
||||
perceptionUpdate [0] >=>
|
||||
targetYouWhenCognizantR >=>
|
||||
return . (crMeleeCooldown %~ max 0 . subtract 1)
|
||||
{ _crUpdate = stateUpdate' $ impulsiveAI $ chainCreatureUpdatesLR
|
||||
[ Right doStrategyActions
|
||||
, Left performActions
|
||||
, Right overrideMeleeCloseTarget
|
||||
, Right setViewPos'
|
||||
, Right setMvPos'
|
||||
, Left goToTarget'
|
||||
, Left $ perceptionUpdate' [0]
|
||||
, Left targetYouWhenCognizant
|
||||
, Right (crMeleeCooldown %~ max 0 . subtract 1)
|
||||
]
|
||||
, _crHP = 300
|
||||
, _crPict = basicCrPict green
|
||||
, _crInv = IM.fromList [(0,medkit 200)]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user