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