Add frame clock
This commit is contained in:
@@ -69,6 +69,16 @@ performPathTo cr w p
|
||||
cpos = _crPos cr
|
||||
jit = _mvTurnJit $ _crMvType cr
|
||||
|
||||
performTurnToA :: Creature -> Point2 -> OutAction
|
||||
performTurnToA cr p
|
||||
| angleVV cdirv dirv < 0.1 = ([], Nothing)
|
||||
| otherwise = ([MvTurnToward p,RandomTurn jit] , Just (TurnToA p))
|
||||
where
|
||||
cpos = _crPos cr
|
||||
cdirv = unitVectorAtAngle (_crDir cr)
|
||||
dirv = p -.- cpos
|
||||
jit = _mvTurnJit $ _crMvType cr
|
||||
|
||||
{- | Performing an action means that a creature has some impulses for a frame, and
|
||||
updates or deletes the action itself.
|
||||
-- doAction -}
|
||||
@@ -108,13 +118,14 @@ performAction cr w ac = case ac of
|
||||
in (concat imps, Just . DoActions $ catMaybes newAcs)
|
||||
StartSentinelPost -> ([AddGoal $ SentinelAt (_crPos cr) (_crDir cr)], Nothing)
|
||||
PathTo p -> performPathTo cr w p
|
||||
LeadTarget p -> case cr ^? crTarget . _Just of
|
||||
TurnToA p -> performTurnToA cr p
|
||||
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 ^? crTarget . _Just
|
||||
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 $ _crMvTarget cr
|
||||
UseMvTargetPos f -> performAction cr w $ f $ _mvToPoint $ _crIntention cr
|
||||
ArbitraryAction f -> performAction cr w (f cr w)
|
||||
DoImpulsesAlongside sideImp mainAc -> case performAction cr w mainAc of
|
||||
(imp, Just nxtac) -> (sideImp ++ imp, Just $ DoImpulsesAlongside sideImp nxtac)
|
||||
|
||||
Reference in New Issue
Block a user