Commit before attempting to add concurrency to loop

This commit is contained in:
2022-08-16 08:00:47 +01:00
parent 9e3097d681
commit 919a179283
12 changed files with 129 additions and 138 deletions
+27 -32
View File
@@ -1,7 +1,6 @@
module Dodge.Projectile.Create where
import Dodge.Data.World
import Dodge.Item.Location
import Geometry
import qualified IntMapHelp as IM
import LensHelp
@@ -30,24 +29,22 @@ fireShell it cr =
makeShell :: Item -> Creature -> [ProjectileUpdate] -> World -> World
makeShell it cr theupdate w =
w & cWorld . projectiles
%~ IM.insert
i
Shell
{ _prjPos = pos
, _prjZ = 20
, _prjStartPos = pos
, _prjVel = rotateV dir (V2 1 0)
, _prjDraw = DrawShell
, _prjID = i
, _prjAcc = rotateV dir (V2 3 0)
, _prjDir = dir
, _prjSpin = 0
, _prjPayload = _amPayload $ _laAmmoType am
, _prjTimer = 350
, _prjUpdates = theupdate
, _prjMITID = Just $ _itID it
}
w & cWorld . projectiles . at i
?~ Shell
{ _prjPos = pos
, _prjZ = 20
, _prjStartPos = pos
, _prjVel = rotateV dir (V2 1 0)
, _prjDraw = DrawShell
, _prjID = i
, _prjAcc = rotateV dir (V2 3 0)
, _prjDir = dir
, _prjSpin = 0
, _prjPayload = _amPayload $ _laAmmoType am
, _prjTimer = 350
, _prjUpdates = theupdate
, _prjMITID = Just $ _itID it
}
where
i = IM.newKey $ _props (_cWorld w)
dir = _crDir cr
@@ -55,20 +52,18 @@ makeShell it cr theupdate w =
am = _heldConsumption $ _itUse it
fireTrackingShell :: Item -> Creature -> World -> World
fireTrackingShell it cr w = addTrackRocket w'
fireTrackingShell it cr =
makeShell
it
cr
[ PJRemoteShellCollisionCheck
, PJDecTimMvVel
, PJSpin 335 (_crID cr) spinamount
, PJTrack (350 - thrustdelay) 0 (_itID it)
, PJThrust (350 - thrustdelay) 0
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
]
where
(w', itid) = getHeldItemLoc cr w
addTrackRocket =
makeShell
it
cr
[ PJRemoteShellCollisionCheck
, PJDecTimMvVel
, PJSpin 335 (_crID cr) spinamount
, PJTrack (350 - thrustdelay) 0 itid
, PJThrust (350 - thrustdelay) 0
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
]
spinamount = _shellSpinAmount params
thrustdelay = _shellThrustDelay params
spindrag = _shellSpinDrag params
+4 -4
View File
@@ -33,8 +33,8 @@ updateProjectile pj = case pj of
shellCollisionCheck :: (Proj -> World -> World) -> Proj -> World -> World
shellCollisionCheck doExplode pj w
| time > 340 && circOnSomeWall oldPos 4 w = doExplode pj w
| time <= 340 && anythingHitCirc 2 oldPos newPos w = doExplode pj w
| time > 330 && circOnSomeWall oldPos 4 w = doExplode pj w
| time <= 330 && anythingHitCirc 2 oldPos newPos w = doExplode pj w
| time <= 0 = doExplode pj w
| otherwise = w
where
@@ -48,8 +48,8 @@ remoteShellCollisionCheck = shellCollisionCheck $ \pj -> explodeRemoteRocket (fr
plainShellCollisionCheck :: Proj -> World -> World
plainShellCollisionCheck = shellCollisionCheck $ \pj ->
(usePayload (_prjPayload pj) (_prjPos pj))
. (stopSoundFrom (ShellSound (_prjID pj)))
usePayload (_prjPayload pj) (_prjPos pj)
. stopSoundFrom (ShellSound (_prjID pj))
. (cWorld . projectiles %~ IM.delete (_prjID pj))
upsProjectile :: Proj -> World -> World