Refactor crPos to be a V3
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
|
||||
module Dodge.Creature.Impulse (
|
||||
impulsiveAIBefore,
|
||||
) where
|
||||
module Dodge.Creature.Impulse (impulsiveAIBefore) where
|
||||
|
||||
import Linear
|
||||
import NewInt
|
||||
import Dodge.Creature.MoveType
|
||||
import Data.Foldable
|
||||
@@ -58,7 +57,7 @@ followImpulse cr w imp = case imp of
|
||||
, crMvAbsolute (w ^. cWorld . lWorld) (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crType . meleeCooldown .~ 20
|
||||
)
|
||||
RandomTurn a -> (randGen .~ snd (rr a), cr & crDir +~ fst (rr a))
|
||||
MakeSound sid -> (soundStart (CrSound (_crID cr)) (_crPos cr) sid Nothing, cr)
|
||||
MakeSound sid -> (soundStart (CrSound (_crID cr)) (cr ^. crPos . _xy) sid Nothing, cr)
|
||||
DropItem -> undefined
|
||||
ChangeStrategy strat -> crup $ cr & crActionPlan . apStrategy .~ strat
|
||||
AddGoal gl -> crup $ cr & crActionPlan . apGoal .:~ gl
|
||||
@@ -71,7 +70,7 @@ followImpulse cr w imp = case imp of
|
||||
ImpulseUseTarget f -> case cr ^? crIntention . targetCr . _Just of
|
||||
Just tcr -> followImpulse cr w (doCrImp f tcr)
|
||||
_ -> crup cr
|
||||
ImpulseUseAheadPos f -> followImpulse cr w (doP2Imp f (_crPos cr +.+ 20 *.* unitVectorAtAngle (_crDir cr)))
|
||||
ImpulseUseAheadPos f -> followImpulse cr w (doP2Imp f (cr ^. crPos . _xy +.+ 20 *.* unitVectorAtAngle (_crDir cr)))
|
||||
MvForward -> crup $ crMvForward speed (w ^. cWorld . lWorld) cr
|
||||
MvTurnToward p ->
|
||||
crup $
|
||||
@@ -81,10 +80,10 @@ followImpulse cr w imp = case imp of
|
||||
mvType = crMvType cr
|
||||
speed = _mvSpeed mvType
|
||||
turnRad = doFloatFloat $ _mvTurnRad mvType
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
cdir = _crDir cr
|
||||
cid = _crID cr
|
||||
posFromID cid' = w ^?! cWorld . lWorld . creatures . ix cid' . crPos
|
||||
posFromID cid' = w ^?! cWorld . lWorld . creatures . ix cid' . crPos . _xy
|
||||
rr a = randomR (- a, a) $ _randGen w
|
||||
hitCr i =
|
||||
cWorld . lWorld . creatures . ix i . crDamage
|
||||
|
||||
Reference in New Issue
Block a user