Refactor crPos to be a V3

This commit is contained in:
2025-10-10 13:47:31 +01:00
parent 98ece551c7
commit 49fb982877
58 changed files with 375 additions and 307 deletions
+4 -3
View File
@@ -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