Remove Reader from chaseCrit
This commit is contained in:
@@ -16,7 +16,6 @@ import Picture
|
|||||||
|
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
--import Control.Monad.Reader
|
|
||||||
|
|
||||||
armourChaseCrit :: Creature
|
armourChaseCrit :: Creature
|
||||||
armourChaseCrit = defaultCreature
|
armourChaseCrit = defaultCreature
|
||||||
@@ -25,7 +24,7 @@ armourChaseCrit = defaultCreature
|
|||||||
, Right doStrategyActions
|
, Right doStrategyActions
|
||||||
, Left performActions
|
, Left performActions
|
||||||
, Left targetYouWhenCognizant
|
, Left targetYouWhenCognizant
|
||||||
, Left $ setTargetMv' (\_ -> _targetCr . _crIntention)
|
, Left $ setTargetMv (\_ -> _targetCr . _crIntention)
|
||||||
, Left flockACC
|
, Left flockACC
|
||||||
, Left $ perceptionUpdate' [0]
|
, Left $ perceptionUpdate' [0]
|
||||||
, Left goToTarget'
|
, Left goToTarget'
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ module Dodge.Creature.ChaseCrit
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
import Dodge.Creature.Picture
|
import Dodge.Creature.Picture
|
||||||
|
import Dodge.Creature.ChainUpdates
|
||||||
import Dodge.Creature.ReaderUpdate
|
import Dodge.Creature.ReaderUpdate
|
||||||
import Dodge.Creature.Impulse
|
import Dodge.Creature.Impulse
|
||||||
import Dodge.Creature.Action
|
import Dodge.Creature.Action
|
||||||
@@ -20,7 +21,6 @@ import Picture
|
|||||||
--import Data.Maybe
|
--import Data.Maybe
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad
|
|
||||||
--import System.Random
|
--import System.Random
|
||||||
|
|
||||||
smallChaseCrit :: Creature
|
smallChaseCrit :: Creature
|
||||||
@@ -33,17 +33,17 @@ smallChaseCrit = chaseCrit
|
|||||||
}
|
}
|
||||||
chaseCrit :: Creature
|
chaseCrit :: Creature
|
||||||
chaseCrit = defaultCreature
|
chaseCrit = defaultCreature
|
||||||
{ _crUpdate = stateUpdate $ --dummyUpdate
|
{ _crUpdate = stateUpdate' $ impulsiveAI $ chainCreatureUpdatesLR
|
||||||
impulsiveAIR $
|
[ Right doStrategyActions
|
||||||
doStrategyActionsR >=>
|
, Left performActions
|
||||||
performActionsR >=>
|
, Right overrideMeleeCloseTarget
|
||||||
overrideMeleeCloseTargetR >=>
|
, Right setViewPos'
|
||||||
setViewPos >=>
|
, Right setMvPos'
|
||||||
setMvPos >=>
|
, Left goToTarget'
|
||||||
goToTarget >=>
|
, Left $ perceptionUpdate' [0]
|
||||||
perceptionUpdate [0] >=>
|
, Left targetYouWhenCognizant
|
||||||
targetYouWhenCognizantR >=>
|
, Right (crMeleeCooldown %~ max 0 . subtract 1)
|
||||||
return . (crMeleeCooldown %~ max 0 . subtract 1)
|
]
|
||||||
, _crHP = 300
|
, _crHP = 300
|
||||||
, _crPict = basicCrPict green
|
, _crPict = basicCrPict green
|
||||||
, _crInv = IM.fromList [(0,medkit 200)]
|
, _crInv = IM.fromList [(0,medkit 200)]
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ module Dodge.Creature.ReaderUpdate
|
|||||||
( doStrategyActionsR
|
( doStrategyActionsR
|
||||||
, doStrategyActions
|
, doStrategyActions
|
||||||
, setTargetMv
|
, setTargetMv
|
||||||
, setTargetMv'
|
|
||||||
, targetYouWhenCognizantR
|
, targetYouWhenCognizantR
|
||||||
, targetYouWhenCognizant
|
, targetYouWhenCognizant
|
||||||
, overrideMeleeCloseTargetR
|
, overrideMeleeCloseTargetR
|
||||||
@@ -19,7 +18,9 @@ module Dodge.Creature.ReaderUpdate
|
|||||||
, flockACCR
|
, flockACCR
|
||||||
, flockACC
|
, flockACC
|
||||||
, setMvPos
|
, setMvPos
|
||||||
|
, setMvPos'
|
||||||
, setViewPos
|
, setViewPos
|
||||||
|
, setViewPos'
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
@@ -62,33 +63,32 @@ setMvPos cr = pure $ cr & crIntention . mvToPoint .~ mpos
|
|||||||
mpos = (_crPos <$> _targetCr int)
|
mpos = (_crPos <$> _targetCr int)
|
||||||
<|> _mvToPoint int
|
<|> _mvToPoint int
|
||||||
-- <|> listToMaybe (_soundsToInvestigate $ _crMemory cr)
|
-- <|> 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 :: Creature -> Reader World Creature
|
||||||
setViewPos cr = pure $ cr & crIntention . viewPoint %~ (<|> mpos)
|
setViewPos cr = pure $ cr & crIntention . viewPoint %~ (<|> mpos)
|
||||||
where
|
where
|
||||||
mpos = listToMaybe (_soundsToInvestigate $ _crMemory cr)
|
mpos = listToMaybe (_soundsToInvestigate $ _crMemory cr)
|
||||||
|
|
||||||
setTargetMv
|
setViewPos' :: Creature -> Creature
|
||||||
:: (Creature -> Reader World (Maybe Creature)) -- ^ Function for determining target
|
setViewPos' cr = cr & crIntention . viewPoint %~ (<|> mpos)
|
||||||
-> Creature
|
where
|
||||||
-> Reader World Creature
|
mpos = listToMaybe (_soundsToInvestigate $ _crMemory cr)
|
||||||
setTargetMv targFunc cr = do
|
|
||||||
targ <- targFunc cr
|
|
||||||
case targ of
|
|
||||||
Nothing -> pure cr
|
|
||||||
Just crTarg -> pure $ cr & crIntention . mvToPoint ?~ _crPos crTarg
|
|
||||||
|
|
||||||
setTargetMv'
|
setTargetMv :: (World -> Creature -> Maybe Creature) -- ^ Function for determining target
|
||||||
:: (World -> Creature -> Maybe Creature) -- ^ Function for determining target
|
-> World -> Creature -> Creature
|
||||||
-> World
|
setTargetMv targFunc w cr = maybe
|
||||||
-> Creature
|
cr
|
||||||
-> Creature
|
(\ctarg -> cr & crIntention . mvToPoint ?~ _crPos ctarg)
|
||||||
setTargetMv' targFunc w cr = maybe cr (\ctarg -> cr & crIntention . mvToPoint ?~ _crPos ctarg)
|
|
||||||
(targFunc w cr)
|
(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 :: Creature -> Reader World Creature
|
||||||
flockACCR cr = do
|
flockACCR cr = do
|
||||||
case cr ^? crIntention . targetCr . _Just of
|
case cr ^? crIntention . targetCr . _Just of
|
||||||
|
|||||||
Reference in New Issue
Block a user