Implement targeting launcher shells using separate item

This commit is contained in:
2024-09-29 16:24:26 +01:00
parent 7d72fa3c5d
commit 88c3e02459
36 changed files with 747 additions and 610 deletions
+26 -10
View File
@@ -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