Refactor
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
module Dodge.Creature.Action.Movement
|
||||
where
|
||||
import Dodge.Data
|
||||
import Geometry
|
||||
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
|
||||
strafeTo :: Float -> Point2 -> Int -> World -> World
|
||||
strafeTo speed targPos cid w = over (creatures . ix cid . crPos) (+.+ q) w
|
||||
where q = (*.*) (speed * equipFactor * wpFactor)
|
||||
$ safeNormalizeV $ (targPos -.- _crPos cr)
|
||||
equipFactor = product $ map equipSpeed $ IM.elems $ _crInv $ _creatures w IM.! cid
|
||||
cr = _creatures w IM.! cid
|
||||
wpFactor = _itAimingSpeed (_crInv cr IM.! _crInvSel cr)
|
||||
|
||||
{- Determine the speed modifier of an item. -}
|
||||
equipSpeed :: Item -> Float
|
||||
equipSpeed NoItem = 1
|
||||
equipSpeed it | _itIdentity it == FrontArmour = 0.75
|
||||
| _itIdentity it == FlameShield = 0.75
|
||||
| otherwise = 1
|
||||
Reference in New Issue
Block a user