Continue projectile udpate refactor
This commit is contained in:
@@ -22,16 +22,17 @@ import NewInt
|
||||
import RandomHelp
|
||||
|
||||
updateProjectile :: Projectile -> World -> World
|
||||
updateProjectile pj w = foldl' (flip $ upProjectile pj) w (_pjUpdates pj)
|
||||
|
||||
upProjectile :: Projectile -> ProjectileUpdate -> World -> World
|
||||
upProjectile pj pu = case pu of
|
||||
CollisionEffectPU ->
|
||||
updateProjectile pj w =
|
||||
decTimMvVel pj .
|
||||
shellCollisionCheck
|
||||
(pj ^. pjDetonatorID)
|
||||
(pj ^. pjScreenID)
|
||||
pj
|
||||
TimePU -> decTimMvVel pj
|
||||
pj $
|
||||
foldl' (flip $ upProjectile pj) w (_pjUpdates pj)
|
||||
|
||||
upProjectile :: Projectile -> ProjectileUpdate -> World -> World
|
||||
upProjectile pj pu = case pu of
|
||||
-- TimePU -> decTimMvVel pj
|
||||
ThrustPU st et
|
||||
| act st et -> doThrust pj (pj ^? pjType . rkSmoke . _Just)
|
||||
| otherwise -> id
|
||||
@@ -42,10 +43,10 @@ upProjectile pj pu = case pu of
|
||||
| act st et -> pjRemoteSetDirection (pj ^? pjType . rkHoming) pj
|
||||
| otherwise -> id
|
||||
ReduceSpinPU x -> reduceSpinBy x (_pjID pj)
|
||||
DestroyPU mitid 0 -> destroyProjectile mitid (_pjID pj)
|
||||
-- DestroyPU mitid 0 -> destroyProjectile mitid (_pjID pj)
|
||||
-- the following requires that this is at the top of the update list, which is
|
||||
-- not ideal
|
||||
DestroyPU _ _ -> cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates . ix 0 . pjuTimer -~ 1
|
||||
-- DestroyPU _ _ -> cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates . ix 0 . pjuTimer -~ 1
|
||||
ApplyGravityPU -> applyGravityPU pj
|
||||
where
|
||||
time = _pjTimer pj
|
||||
@@ -87,6 +88,10 @@ shellCollisionCheck ::
|
||||
World ->
|
||||
World
|
||||
shellCollisionCheck detid screenid pj w
|
||||
| RetiredProjectile <- pj ^. pjType
|
||||
, time <= -30
|
||||
= destroyProjectile (pj ^. pjScreenID) (_pjID pj) w
|
||||
| RetiredProjectile <- pj ^. pjType = w
|
||||
| anythingHitCirc 2 oldPos (oldPos + _pjVel pj) w = g
|
||||
| time <= 0 = g
|
||||
| otherwise = w
|
||||
@@ -186,7 +191,8 @@ explodeShell ::
|
||||
World
|
||||
explodeShell mdetid screenid pj w =
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix pjid . pjUpdates .~ [DestroyPU screenid 30]
|
||||
-- & cWorld . lWorld . projectiles . ix pjid . pjUpdates .~ [DestroyPU screenid 30]
|
||||
& cWorld . lWorld . projectiles . ix pjid . pjType .~ RetiredProjectile
|
||||
& usePayload (_pjPayload pj) (_pjPos pj) (_pjVel pj)
|
||||
& stopSoundFrom (ShellSound pjid)
|
||||
& updatedetonator
|
||||
|
||||
Reference in New Issue
Block a user