{-# LANGUAGE StrictData #-} {-# LANGUAGE TemplateHaskell #-} module Dodge.Data.ActionPlan where import Control.Lens import Data.Aeson import Data.Aeson.TH import Dodge.Data.Creature.Stance import Dodge.Data.CreatureEffect import Geometry.Data import Sound.Data data ActionPlan = Inanimate | SlimeIntelligence | ActionPlan { -- _apImpulse :: [Impulse] -- done per frame _apAction :: Action -- updated per frame, likely persist across frames , _apStrategy :: Strategy , _apGoal :: Goal } --deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show) --Generic, Flat) data Impulse = Move Point2 | Walk Point2 | MoveForward Float | MoveNoStride Point2 | Turn Float | RandomTurn Float | RandomImpulse RandImpulse -- (State StdGen Impulse) | TurnToward Point2 Float | MvTurnToward Point2 | MvForward | TurnTo Point2 | UseItem -- | SwitchToItem Int | DropItem | Bark SoundID -- placeholder for various communication types | Melee Int | MeleeL Int | MeleeR Int | ChangePosture Posture | MakeSound SoundID | ChangeStrategy Strategy -- | AddGoal Goal | ImpulseUseTarget { _impulseUseTarget :: CrImp } | ImpulseNothing | UpdateRandGen | SetBeeRandomMovement deriving (Eq, Ord, Show) --Generic, Flat) data RandImpulse = RandImpulseList [Impulse] | RandImpulseCircMove Float deriving (Eq, Ord, Show) --Generic, Flat) infixr 9 `WaitThen` infixr 9 `DoActionThen` --infixr 9 `DoActionWhile` infixr 9 `DoReplicate` infixr 9 `DoImpulsesAlongside` data Action = AimAt { _targetID :: Int , _targetSeenAt :: Point2 } | PathTo { _pathToPoint :: Point2, _pathFailAction :: Action } | Eat {_targetID :: Int, _acTimer :: Int} | EvadeAim | TurnToPoint { _turnToPoint :: Point2 } | ImpulsesList { _impulsesListList :: [[Impulse]], _acAction :: Action } | DoImpulses { _doImpulsesList :: [Impulse] } | WaitThen { _waitThenTimer :: Int , _waitThenAction :: Action } | DoActionWhilePartial { _doActionWhilePartial :: Action , _doActionWhileCondition :: WdCrBl , _doActionWhileAction :: Action } | DoActionIf { _doActionIfCondition :: WdCrBl , _doActionIfAction :: Action } | DoActionIfElse { _doActionIfElseIfAction :: Action , _doActionIfElseCondition :: WdCrBl , _doActionIfElseElseAction :: Action } | DoActionWhileInterrupt { _doActionWhileThenDo :: Action , _doActionWhileThenCondition :: WdCrBl , _doActionWhileThenThen :: Action } -- | DoActions { _doActionsList :: [Action] } | DoActionThen { _doActionThenFirst :: Action , _doActionThenSecond :: Action } | DoReplicate { _doReplicateTimes :: Int , _doReplicateAction :: Action } | DoReplicatePartial { _partialAction :: Action , _doReplicateTimes :: Int , _doReplicateAction :: Action } | LeadTarget { _leadTargetBy :: Point2 } | NoAction -- | Repeatedly perform impulses alongside a main action until the main action terminates | DoImpulsesAlongside { _sideImpulses :: [Impulse] , _mainAction :: Action } deriving (Eq, Ord, Show) --Generic, Flat) --deriving (Eq, Ord, Show, Read) --Generic, Flat) data Strategy = Flank {_flankTarget :: Int} | Ambush {_ambushTarget :: Int} | Lure Int Point2 | Patrol [Point2] | ShootAt Int -- | FollowImpulses | WatchAndWait | Investigate | WarningCry | LookAround | Wander | CloseToMelee {_meleeTarget :: Int} | GetTo Point2 | Search | SearchTimed {_searchTimer :: Int} | ReturnToHive | HarvestFrom {_harvestTarget :: Int} | StrategyInt {_strategyInt :: Int} deriving (Eq, Ord, Show) --Generic, Flat) --deriving (Eq, Ord, Show, Read) --Generic, Flat) data Goal = LiveLongAndProsper | SearchForFood | Flee | Kill {_killTarget :: Int} | SentinelAt {_sentinelPos :: Point2, _sentinelDir :: Float} deriving (Eq, Ord, Show) --Generic, Flat) --deriving (Eq, Ord, Show, Read) --Generic, Flat) concat <$> mapM (deriveJSON defaultOptions) [ ''Impulse , ''RandImpulse , ''Action , ''Strategy , ''ActionPlan , ''Goal ] makeLenses ''ActionPlan makeLenses ''Impulse makeLenses ''Action makeLenses ''Strategy