ActionPlan refactor
This commit is contained in:
@@ -100,6 +100,7 @@ performTurnToA cr p
|
||||
-- doAction -}
|
||||
performAction :: Creature -> World -> Action -> OutAction
|
||||
performAction cr w ac = case ac of
|
||||
ActionNothing -> ([],Nothing)
|
||||
LabelAction str subAc -> second (fmap (LabelAction str)) $ performAction cr w subAc
|
||||
AimAt tcid p -> performAimAt cr w tcid p
|
||||
WaitThen 0 newAc -> ([] , Just newAc)
|
||||
@@ -135,11 +136,11 @@ performAction cr w ac = case ac of
|
||||
LeadTarget p -> case cr ^? crIntention . targetCr . _Just of
|
||||
Just tcr -> ([TurnTo (_crPos tcr +.+ rotateV (_crDir tcr) p)], Nothing)
|
||||
_ -> ([], Nothing)
|
||||
UseTarget f -> performAction cr w $ f $ cr ^? crIntention . targetCr . _Just
|
||||
UseSelf f -> performAction cr w $ f cr
|
||||
UseAheadPos f -> performAction cr w (f (_crPos cr +.+ 20 *.* unitVectorAtAngle (_crDir cr)))
|
||||
UseMvTargetPos f -> performAction cr w $ f $ _mvToPoint $ _crIntention cr
|
||||
ArbitraryAction f -> performAction cr w (f cr w)
|
||||
UseTarget f -> performAction cr w $ doMCrAc f $ cr ^? crIntention . targetCr . _Just
|
||||
UseSelf f -> performAction cr w $ doCrAc f cr
|
||||
UseAheadPos f -> performAction cr w (doP2Ac f (_crPos cr +.+ 20 *.* unitVectorAtAngle (_crDir cr)))
|
||||
UseMvTargetPos f -> performAction cr w $ doMP2Ac f $ _mvToPoint $ _crIntention cr
|
||||
ArbitraryAction f -> performAction cr w (doCrWdAc f cr w)
|
||||
DoImpulsesAlongside sideImp mainAc -> case performAction cr w mainAc of
|
||||
(imp, Just nxtac) -> (sideImp ++ imp, Just $ DoImpulsesAlongside sideImp nxtac)
|
||||
(imp, _) -> (sideImp ++ imp, Nothing)
|
||||
|
||||
Reference in New Issue
Block a user