Cleanup movement

This commit is contained in:
2022-05-21 22:53:25 +01:00
parent 5550b5eb95
commit ee31fcbdd9
2 changed files with 22 additions and 19 deletions
+21 -13
View File
@@ -3,28 +3,36 @@ import Dodge.Data
import Geometry
import Data.Maybe
import qualified Data.IntMap.Strict as IM
--import qualified Data.IntMap.Strict as IM
import Control.Lens
{- | Creature attempts to moves under its own steam.
The idea is that this may or may not work, depending on the status of the creature.
For now, though, this cannot fail. -}
--crMvBy
-- :: Point2 -- ^ Movement translation vector, will be made relative to creature direction
-- -> Creature
-- -> Creature
--crMvBy p' cr = advanceStepCounter (magV p) cr
-- & crPos %~ (+.+ p)
-- & crMvDir .~ argV p
-- where
-- p = (*.*) (equipFactor * aimingFactor) $ rotateV (_crDir cr) p'
-- equipFactor
-- | _posture (_crStance cr) == Aiming
-- = product $ map equipAimSpeed $ IM.elems $ _crInv cr
-- | otherwise = product $ map equipSpeed $ IM.elems $ _crInv cr
-- aimingFactor
-- | _posture (_crStance cr) == Aiming = fromMaybe 1 $ it ^? itUse . useAim . aimSpeed
-- | otherwise = 1
-- it = _crInv cr IM.! _crInvSel cr
crMvBy
:: Point2 -- ^ Movement translation vector, will be made relative to creature direction
-> Creature
-> Creature
crMvBy p' cr = advanceStepCounter (magV p) cr
& crPos %~ (+.+ p)
& crMvDir .~ argV p
crMvBy p' cr = crMvAbsolute p cr
where
p = (*.*) (equipFactor * aimingFactor) $ rotateV (_crDir cr) p'
equipFactor
| _posture (_crStance cr) == Aiming
= product $ map equipAimSpeed $ IM.elems $ _crInv cr
| otherwise = product $ map equipSpeed $ IM.elems $ _crInv cr
aimingFactor
| _posture (_crStance cr) == Aiming = fromMaybe 1 $ it ^? itUse . useAim . aimSpeed
| otherwise = 1
it = _crInv cr IM.! _crInvSel cr
p = rotateV (_crDir cr) p'
crMvAbsolute
:: Point2 -- ^ Movement translation vector