Implement targeting launcher shells using separate item
This commit is contained in:
@@ -3,6 +3,7 @@ module Dodge.Projectile.Update
|
||||
( updateProjectile
|
||||
) where
|
||||
|
||||
import Dodge.Movement.Turn
|
||||
import NewInt
|
||||
import Dodge.Payload
|
||||
import Control.Lens
|
||||
@@ -108,16 +109,31 @@ trySpinByCID cid i pj w = w & cWorld . lWorld . projectiles . ix pjid . prjSpin
|
||||
spinFactor = 5 * (6 - fromIntegral i)
|
||||
|
||||
-- note this only allows YOU to remotely track projectiles
|
||||
pjRemoteSetDirection :: Maybe (NewInt ItmInt) -> Projectile -> World -> World
|
||||
pjRemoteSetDirection mscreenid pj w = fromMaybe w $ do
|
||||
screenid <- fmap _unNInt mscreenid
|
||||
let newdir
|
||||
| w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem
|
||||
== w ^? cWorld . lWorld . itemLocations . ix screenid . ilInvID
|
||||
= (w ^. wCam . camRot) + argV (_mousePos (_input w))
|
||||
| otherwise = _prjDir pj
|
||||
turntonewdir = magV (_prjAcc pj) *.* unitVectorAtAngle newdir
|
||||
return $ w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc .~ turntonewdir
|
||||
pjRemoteSetDirection :: ProjectileHoming -> Projectile -> World -> World
|
||||
pjRemoteSetDirection ph pj w = case ph of
|
||||
NoHoming -> w
|
||||
HomeUsingRemoteScreen screenid ->
|
||||
let newdir
|
||||
| w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem
|
||||
== w ^? cWorld . lWorld . itemLocations . ix (_unNInt screenid) . ilInvID
|
||||
= (w ^. wCam . camRot) + argV (_mousePos (_input w))
|
||||
| otherwise = _prjDir pj
|
||||
in w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc
|
||||
.~ magV (_prjAcc pj) *.* unitVectorAtAngle newdir
|
||||
HomeUsingTargeting itid -> fromMaybe w $ do
|
||||
tp <- w ^? pointerToItemID itid . itUse . tgPos . _Just
|
||||
return $ w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc
|
||||
%~ vecTurnTo 0.2 (_prjPos pj) tp
|
||||
|
||||
--pjRemoteSetDirection mscreenid pj w = fromMaybe w $ do
|
||||
-- screenid <- fmap _unNInt mscreenid
|
||||
-- let newdir
|
||||
-- | w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem
|
||||
-- == w ^? cWorld . lWorld . itemLocations . ix screenid . ilInvID
|
||||
-- = (w ^. wCam . camRot) + argV (_mousePos (_input w))
|
||||
-- | otherwise = _prjDir pj
|
||||
-- turntonewdir = magV (_prjAcc pj) *.* unitVectorAtAngle newdir
|
||||
-- return $ w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc .~ turntonewdir
|
||||
|
||||
reduceSpinBy :: Float -> Int -> World -> World
|
||||
reduceSpinBy x pjid = cWorld . lWorld . projectiles . ix pjid . prjSpin *~ x
|
||||
|
||||
Reference in New Issue
Block a user