Refactor crPos to be a V3
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
module Dodge.Creature.Impulse.Flee where
|
||||
|
||||
import Control.Lens
|
||||
import Linear
|
||||
import Dodge.Data.World
|
||||
import FoldableHelp
|
||||
import Geometry
|
||||
|
||||
retreatPointForFrom ::
|
||||
Float -> World -> Creature -> Point2 -> Maybe Point2
|
||||
retreatPointForFrom :: Float -> World -> Creature -> Point2 -> Maybe Point2
|
||||
retreatPointForFrom d _ cr p =
|
||||
safeMinimumOn (dist cpos) $
|
||||
divideCircle 10 p d
|
||||
where
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
|
||||
-- = head $ sortBy (compare `on` (\p -> dist p ypos < 300)) $ retreatP'' : retreatPs
|
||||
-- where
|
||||
|
||||
@@ -7,6 +7,7 @@ module Dodge.Creature.Impulse.Movement (
|
||||
creatureTurnTo,
|
||||
) where
|
||||
|
||||
import Linear
|
||||
import Control.Lens
|
||||
import Dodge.Base
|
||||
import Dodge.Creature.Statistics
|
||||
@@ -28,7 +29,7 @@ crMvBy p lw cr = crMvAbsolute lw (rotateV (_crDir cr) p) cr
|
||||
crMvAbsolute :: LWorld -> Point2 -> Creature -> Creature
|
||||
crMvAbsolute lw p' cr =
|
||||
advanceStepCounter (magV p) cr
|
||||
& crPos +~ p
|
||||
& crPos . _xy +~ p
|
||||
& crMvDir .~ argV p
|
||||
where
|
||||
p = strengthFactor (getCrMoveSpeed lw cr) *.* p'
|
||||
@@ -55,7 +56,7 @@ creatureTurnTo p cr
|
||||
| vToTarg == V2 0 0 = cr -- this should deal with the angleVV error
|
||||
| otherwise = cr & crDir .~ dirToTarget
|
||||
where
|
||||
vToTarg = p -.- _crPos cr
|
||||
vToTarg = p -.- cr ^. crPos . _xy
|
||||
dirToTarget = argV vToTarg
|
||||
|
||||
-- the following is perhaps not ideal because it mixes normalizeAngle with
|
||||
@@ -80,5 +81,5 @@ creatureTurnToward p turnSpeed cr
|
||||
| isLeftOfA (normalizeAngle dirToTarget) (normalizeAngle $ _crDir cr) = cr & crDir +~ turnSpeed
|
||||
| otherwise = cr & crDir -~ turnSpeed
|
||||
where
|
||||
vToTarg = p -.- _crPos cr
|
||||
vToTarg = p -.- cr ^. crPos . _xy
|
||||
dirToTarget = argV vToTarg
|
||||
|
||||
Reference in New Issue
Block a user