ActionPlan refactor

This commit is contained in:
2022-07-21 22:56:19 +01:00
parent 583027112d
commit dfc9b2dca9
9 changed files with 180 additions and 61 deletions
+9 -10
View File
@@ -15,11 +15,9 @@ module Dodge.Creature.ReaderUpdate
, setViewPos
) where
import Dodge.Data
import Dodge.Creature.Test
import Dodge.Creature.Volition
import Dodge.Base
import Dodge.Zone
import Dodge.Path
import Geometry
import qualified IntMapHelp as IM
@@ -106,7 +104,7 @@ goToTarget w cr =
_ -> viewTarget w cr
lookAroundSelf :: Action
lookAroundSelf = UseSelf $ \cr -> TurnToPoint (_crPos cr -.- 10 *.* unitVectorAtAngle (_crDir cr))
lookAroundSelf = UseSelf CrTurnAround -- $ \cr -> TurnToPoint (_crPos cr -.- 10 *.* unitVectorAtAngle (_crDir cr))
viewTarget :: World -> Creature -> Creature
viewTarget w cr = do
@@ -188,12 +186,13 @@ searchIfDamaged cr
| otherwise = cr
bfsThenReturn :: Int -> Action
bfsThenReturn t = ArbitraryAction theaction
where
theaction cr w = fromMaybe NoAction $ do
n <- walkableNodeNear w (_crPos cr)
let as = take 20 $ map PathTo $ bfsNodePoints n w
return $ DoReplicate t $
foldr DoActionThen NoAction as
bfsThenReturn t = ArbitraryAction (CrWdBFSThenReturn t)
-- theaction
-- where
-- theaction cr w = fromMaybe NoAction $ do
-- n <- walkableNodeNear w (_crPos cr)
-- let as = take 20 $ map PathTo $ bfsNodePoints n w
-- return $ DoReplicate t $
-- foldr DoActionThen NoAction as