Unify launcher projectiles
This commit is contained in:
@@ -39,22 +39,23 @@ shellCollisionCheck doExplode pj w
|
||||
vel = _prjVel pj
|
||||
newPos = oldPos +.+ vel
|
||||
|
||||
remoteShellCollisionCheck :: Int -> Proj -> World -> World
|
||||
remoteShellCollisionCheck screenid = shellCollisionCheck $ \pj -> explodeRemoteRocket screenid (_prjID pj)
|
||||
remoteShellCollisionCheck :: Maybe Int -> Proj -> World -> World
|
||||
remoteShellCollisionCheck mscreenid = shellCollisionCheck
|
||||
$ \pj -> explodeRemoteRocket mscreenid (_prjID pj)
|
||||
|
||||
plainShellCollisionCheck :: Proj -> World -> World
|
||||
plainShellCollisionCheck = shellCollisionCheck $ \pj ->
|
||||
usePayload (_prjPayload pj) (_prjPos pj)
|
||||
. stopSoundFrom (ShellSound (_prjID pj))
|
||||
. (cWorld . lWorld . projectiles %~ IM.delete (_prjID pj))
|
||||
--plainShellCollisionCheck :: Proj -> World -> World
|
||||
--plainShellCollisionCheck = shellCollisionCheck $ \pj ->
|
||||
-- usePayload (_prjPayload pj) (_prjPos pj)
|
||||
-- . stopSoundFrom (ShellSound (_prjID pj))
|
||||
-- . (cWorld . lWorld . projectiles %~ IM.delete (_prjID pj))
|
||||
|
||||
upsProjectile :: Proj -> World -> World
|
||||
upsProjectile pj w' = foldr (`upProjectile` pj) w' (_prjUpdates pj)
|
||||
|
||||
upProjectile :: ProjectileUpdate -> Proj -> World -> World
|
||||
upProjectile pu pj = case pu of
|
||||
PJRemoteShellCollisionCheck screenid -> remoteShellCollisionCheck screenid pj
|
||||
PJShellCollisionCheck -> plainShellCollisionCheck pj
|
||||
PJRemoteShellCollisionCheck mscreenid -> remoteShellCollisionCheck mscreenid pj
|
||||
-- PJShellCollisionCheck -> plainShellCollisionCheck pj
|
||||
PJDecTimMvVel -> decTimMvVel pj
|
||||
PJThrust st et
|
||||
| act st et -> doThrust pj
|
||||
@@ -62,15 +63,15 @@ upProjectile pu pj = case pu of
|
||||
PJSpin t cid spinamount
|
||||
| ain t -> trySpinByCID cid spinamount pj
|
||||
| otherwise -> id
|
||||
PJRemoteSetDirection st et screenid
|
||||
| act st et -> pjRemoteSetDirection screenid pj
|
||||
PJRemoteSetDirection st et mscreenid
|
||||
| act st et -> pjRemoteSetDirection mscreenid pj
|
||||
| otherwise -> id
|
||||
PJReduceSpin x -> reduceSpinBy x pj
|
||||
-- PJRemoteDirection st et cid itid
|
||||
-- | act st et -> setRemoteDir cid itid pj
|
||||
-- | otherwise -> id
|
||||
-- PJSetScope itid -> setRemoteScope itid (_prjPos pj)
|
||||
PJRetireRemote itid 0 pjid -> retireRemoteProj itid pjid
|
||||
PJRetireRemote mitid 0 pjid -> retireRemoteProj mitid pjid
|
||||
-- the following requires that this is at the top of the update list, which is
|
||||
-- not ideal
|
||||
PJRetireRemote _ _ pjid -> cWorld . lWorld . projectiles . ix pjid . prjUpdates . ix 0 . pjuTimer -~ 1
|
||||
@@ -79,40 +80,17 @@ upProjectile pu pj = case pu of
|
||||
act st et = time <= st && time >= et
|
||||
ain t = time == t
|
||||
|
||||
retireRemoteProj :: Int -> Int -> World -> World
|
||||
retireRemoteProj itid pjid w = w & cWorld . lWorld . projectiles %~ IM.delete pjid
|
||||
retireRemoteProj :: Maybe Int -> Int -> World -> World
|
||||
retireRemoteProj mitid pjid w = w & cWorld . lWorld . projectiles %~ IM.delete pjid
|
||||
& removelink
|
||||
where
|
||||
removelink = fromMaybe id $ do
|
||||
itid <- mitid
|
||||
loc <- w ^? cWorld . lWorld . itemLocations . ix itid
|
||||
itm <- w ^? pointerToItemLocation loc . itUse . atLinkedProjectile . _Just
|
||||
guard $ itm == pjid
|
||||
--return $ pointerToItemLocation . itUse . atLinkedProjectile .~ Nothing
|
||||
return $ pointerToItemLocation loc . itUse . atLinkedProjectile .~ Nothing
|
||||
|
||||
|
||||
--retireRemoteProj :: Int -> Int -> World -> World
|
||||
--retireRemoteProj itid pjid w =
|
||||
-- w
|
||||
-- & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix itid)
|
||||
-- %~ ( (itScope . remotePos .~ V2 0 0)
|
||||
-- . (itUse . heldUse .~ HeldFireRemoteShell)
|
||||
-- . (itUse . heldMods .~ FireRemoteShellMod)
|
||||
-- )
|
||||
-- & cWorld . lWorld . props %~ IM.delete pjid
|
||||
|
||||
--setRemoteDir :: Int -> Int -> Proj -> World -> World
|
||||
--setRemoteDir cid itid pj w = w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc .~ turntonewdir
|
||||
-- where
|
||||
-- turntonewdir = magV (_prjAcc pj) *.* unitVectorAtAngle newdir
|
||||
-- --i = _prjID pj
|
||||
-- newdir
|
||||
-- | SDL.ButtonRight `M.member` _mouseButtons (_input w)
|
||||
-- && w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . imSelectedItem
|
||||
-- == w ^? cWorld . lWorld . itemLocations . ix itid . ilInvID
|
||||
-- = (w ^. wCam . camRot) + argV (_mousePos (_input w))
|
||||
-- | otherwise = _prjDir pj
|
||||
|
||||
doThrust :: Proj -> World -> World
|
||||
doThrust pj w =
|
||||
w
|
||||
@@ -166,17 +144,16 @@ trySpinByCID cid i pj w = w & cWorld . lWorld . projectiles . ix pjid . prjSpin
|
||||
-- --itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid
|
||||
|
||||
-- note this only allows YOU to remotely track projectiles
|
||||
pjRemoteSetDirection :: Int -> Proj -> World -> World
|
||||
pjRemoteSetDirection screenid pj w = w
|
||||
& cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc .~ turntonewdir
|
||||
where
|
||||
turntonewdir = magV (_prjAcc pj) *.* unitVectorAtAngle newdir
|
||||
--i = _prjID pj
|
||||
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
|
||||
pjRemoteSetDirection :: Maybe Int -> Proj -> World -> World
|
||||
pjRemoteSetDirection mscreenid pj w = fromMaybe w $ do
|
||||
screenid <- 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
|
||||
|
||||
--pjTrack :: Int -> Proj -> World -> World
|
||||
--pjTrack screenid pj w = w-- rotateToTarget pj w
|
||||
|
||||
Reference in New Issue
Block a user