Move towards fixing remote launcher
This commit is contained in:
@@ -27,6 +27,9 @@ data ProjectileUpdate
|
|||||||
| PJRemoteDirection {_pjuStart :: Int, _pjuEnd :: Int, _pjuCID :: Int, _pjuITID :: Int}
|
| PJRemoteDirection {_pjuStart :: Int, _pjuEnd :: Int, _pjuCID :: Int, _pjuITID :: Int}
|
||||||
| PJSetScope {_pjuITID :: Int}
|
| PJSetScope {_pjuITID :: Int}
|
||||||
| PJRetireRemote {_pjuITID :: Int, _pjuTimer :: Int, _pjuPJID :: Int}
|
| PJRetireRemote {_pjuITID :: Int, _pjuTimer :: Int, _pjuPJID :: Int}
|
||||||
|
| PJDecTimMvVel
|
||||||
|
| PJShellCollisionCheck
|
||||||
|
| PJRemoteShellCollisionCheck
|
||||||
deriving (Show, Read, Eq, Ord)
|
deriving (Show, Read, Eq, Ord)
|
||||||
|
|
||||||
data AmmoType
|
data AmmoType
|
||||||
|
|||||||
@@ -10,16 +10,7 @@ import Dodge.Data.Item.Use.Consumption.Ammo
|
|||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
|
|
||||||
data Proj
|
data Proj
|
||||||
= RemoteShell
|
= Shell
|
||||||
{ _prjPos :: Point2
|
|
||||||
, _prjStartPos :: Point2
|
|
||||||
, _prjVel :: Point2
|
|
||||||
, _prjDraw :: ProjectileDraw
|
|
||||||
, _prjID :: Int
|
|
||||||
, _prjPayload :: Payload
|
|
||||||
, _prjMITID :: Maybe Int
|
|
||||||
}
|
|
||||||
| Shell
|
|
||||||
{ _prjPos :: Point2
|
{ _prjPos :: Point2
|
||||||
, _prjStartPos :: Point2
|
, _prjStartPos :: Point2
|
||||||
, _prjVel :: Point2
|
, _prjVel :: Point2
|
||||||
|
|||||||
@@ -458,7 +458,9 @@ fireRemoteShell it cr w =
|
|||||||
makeShell
|
makeShell
|
||||||
it
|
it
|
||||||
cr
|
cr
|
||||||
[ PJSetScope itid
|
[ PJRemoteShellCollisionCheck
|
||||||
|
, PJSetScope itid
|
||||||
|
, PJDecTimMvVel
|
||||||
, PJThrust 330 0
|
, PJThrust 330 0
|
||||||
, PJRemoteDirection 340 0 cid itid
|
, PJRemoteDirection 340 0 cid itid
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import Dodge.Item.Location
|
|||||||
import Geometry
|
import Geometry
|
||||||
import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
import LensHelp
|
import LensHelp
|
||||||
|
import Data.Maybe
|
||||||
|
|
||||||
createProjectile :: ProjectileCreate -> Item -> Creature -> World -> World
|
createProjectile :: ProjectileCreate -> Item -> Creature -> World -> World
|
||||||
createProjectile pt = case pt of
|
createProjectile pt = case pt of
|
||||||
@@ -16,7 +17,9 @@ fireShell it cr =
|
|||||||
makeShell
|
makeShell
|
||||||
it
|
it
|
||||||
cr
|
cr
|
||||||
[ PJSpin 335 (_crID cr) spinamount
|
[ PJShellCollisionCheck
|
||||||
|
, PJDecTimMvVel
|
||||||
|
, PJSpin 335 (_crID cr) spinamount
|
||||||
, PJThrust (350 - thrustdelay) 0
|
, PJThrust (350 - thrustdelay) 0
|
||||||
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
|
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
|
||||||
]
|
]
|
||||||
@@ -44,7 +47,7 @@ makeShell it cr theupdate w =
|
|||||||
, _prjPayload = _amPayload $ _laAmmoType am
|
, _prjPayload = _amPayload $ _laAmmoType am
|
||||||
, _prjTimer = 350
|
, _prjTimer = 350
|
||||||
, _prjUpdates = theupdate
|
, _prjUpdates = theupdate
|
||||||
, _prjMITID = _itID it
|
, _prjMITID = Just . fromJust $ _itID it
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
i = IM.newKey $ _props (_cWorld w)
|
i = IM.newKey $ _props (_cWorld w)
|
||||||
@@ -198,7 +201,9 @@ fireTrackingShell it cr w = addTrackRocket w'
|
|||||||
makeShell
|
makeShell
|
||||||
it
|
it
|
||||||
cr
|
cr
|
||||||
[ PJSpin 335 (_crID cr) spinamount
|
[ PJRemoteShellCollisionCheck
|
||||||
|
, PJDecTimMvVel
|
||||||
|
, PJSpin 335 (_crID cr) spinamount
|
||||||
, PJTrack (350 - thrustdelay) 0 itid
|
, PJTrack (350 - thrustdelay) 0 itid
|
||||||
, PJThrust (350 - thrustdelay) 0
|
, PJThrust (350 - thrustdelay) 0
|
||||||
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
|
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
|
||||||
|
|||||||
@@ -29,11 +29,31 @@ import qualified Streaming.Prelude as S
|
|||||||
|
|
||||||
updateProjectile :: Proj -> World -> World
|
updateProjectile :: Proj -> World -> World
|
||||||
updateProjectile pj = case pj of
|
updateProjectile pj = case pj of
|
||||||
Shell{} -> updateShell pj . decTimMvVel pj . upsProjectile pj
|
Shell{} -> upsProjectile pj
|
||||||
RemoteShell{} -> updateRemoteShell pj . decTimMvVel pj . upsProjectile pj
|
|
||||||
|
|
||||||
updateRemoteShell :: Proj -> World -> World
|
--explodeRemoteRocket' ::
|
||||||
updateRemoteShell pj w
|
-- -- | Item id
|
||||||
|
---- Maybe Int ->
|
||||||
|
-- Proj ->
|
||||||
|
-- World ->
|
||||||
|
-- World
|
||||||
|
--explodeRemoteRocket' thepj w =
|
||||||
|
-- w
|
||||||
|
-- & cWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||||
|
-- & usePayload (_prjPayload thepj) (_prjPos thepj)
|
||||||
|
-- & updateitem
|
||||||
|
-- where
|
||||||
|
-- mitid = _prjMITID thepj
|
||||||
|
-- updateitem = fromMaybe (cWorld . projectiles . at pjid .~ Nothing) $ do
|
||||||
|
-- itid <- mitid
|
||||||
|
-- itpos <- w ^? cWorld . itemLocations . ix itid
|
||||||
|
-- return $
|
||||||
|
-- (pointerToItemLocation itpos . itUse . heldUse .~ HeldDoNothing)
|
||||||
|
-- . (cWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid])
|
||||||
|
-- pjid = _prjID thepj
|
||||||
|
|
||||||
|
remoteShellCollisionCheck :: Proj -> World -> World
|
||||||
|
remoteShellCollisionCheck pj w
|
||||||
| time > 340 =
|
| time > 340 =
|
||||||
if circOnSomeWall oldPos 4 w
|
if circOnSomeWall oldPos 4 w
|
||||||
then doExplode
|
then doExplode
|
||||||
@@ -43,36 +63,12 @@ updateRemoteShell pj w
|
|||||||
| otherwise = doExplode
|
| otherwise = doExplode
|
||||||
where
|
where
|
||||||
time = _prjTimer pj
|
time = _prjTimer pj
|
||||||
doExplode =
|
doExplode = explodeRemoteRocket (fromJust (_prjMITID pj)) (_prjID pj) w
|
||||||
w
|
|
||||||
& usePayload (_prjPayload pj) oldPos
|
|
||||||
& stopSoundFrom (ShellSound i)
|
|
||||||
& cWorld . projectiles %~ IM.delete i
|
|
||||||
i = _prjID pj
|
i = _prjID pj
|
||||||
oldPos = _prjPos pj
|
oldPos = _prjPos pj
|
||||||
vel = _prjVel pj
|
vel = _prjVel pj
|
||||||
newPos = oldPos +.+ vel
|
newPos = oldPos +.+ vel
|
||||||
|
|
||||||
explodeRemoteRocket' ::
|
|
||||||
-- | Item id
|
|
||||||
Maybe Int ->
|
|
||||||
Proj ->
|
|
||||||
World ->
|
|
||||||
World
|
|
||||||
explodeRemoteRocket' mitid thepj w =
|
|
||||||
w
|
|
||||||
& cWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
|
||||||
& usePayload (_prjPayload thepj) (_prjPos thepj)
|
|
||||||
& updateitem
|
|
||||||
where
|
|
||||||
updateitem = fromMaybe (cWorld . projectiles . at pjid .~ Nothing) $ do
|
|
||||||
itid <- mitid
|
|
||||||
itpos <- w ^? cWorld . itemLocations . ix itid
|
|
||||||
return $
|
|
||||||
(pointerToItemLocation itpos . itUse . heldUse .~ HeldDoNothing)
|
|
||||||
. (cWorld . projectiles . ix pjid . prjUpdates .~ [PJRetireRemote itid 30 pjid])
|
|
||||||
pjid = _prjID thepj
|
|
||||||
|
|
||||||
updateShell :: Proj -> World -> World
|
updateShell :: Proj -> World -> World
|
||||||
updateShell pj w
|
updateShell pj w
|
||||||
| time > 340 =
|
| time > 340 =
|
||||||
@@ -99,6 +95,9 @@ upsProjectile pj w' = foldr (`upProjectile` pj) w' (_prjUpdates pj)
|
|||||||
|
|
||||||
upProjectile :: ProjectileUpdate -> Proj -> World -> World
|
upProjectile :: ProjectileUpdate -> Proj -> World -> World
|
||||||
upProjectile pu pj = case pu of
|
upProjectile pu pj = case pu of
|
||||||
|
PJRemoteShellCollisionCheck -> remoteShellCollisionCheck pj
|
||||||
|
PJShellCollisionCheck -> updateShell pj
|
||||||
|
PJDecTimMvVel -> decTimMvVel pj
|
||||||
PJThrust st et
|
PJThrust st et
|
||||||
| act st et -> doThrust' pj
|
| act st et -> doThrust' pj
|
||||||
| otherwise -> id
|
| otherwise -> id
|
||||||
|
|||||||
Reference in New Issue
Block a user