Cleanup projectile update
This commit is contained in:
@@ -25,8 +25,6 @@ updateProjectile :: Projectile -> World -> World
|
||||
updateProjectile pj w =
|
||||
decTimMvVel pj .
|
||||
shellCollisionCheck
|
||||
(pj ^. pjDetonatorID)
|
||||
(pj ^. pjScreenID)
|
||||
pj $
|
||||
foldl' (flip $ upProjectile pj) w (_pjUpdates pj)
|
||||
|
||||
@@ -82,12 +80,10 @@ applyGravityPU pj w
|
||||
|
||||
-- consider using thingHit, pushing any hit creature back
|
||||
shellCollisionCheck ::
|
||||
Maybe (NewInt ItmInt) ->
|
||||
Maybe (NewInt ItmInt) ->
|
||||
Projectile ->
|
||||
World ->
|
||||
World
|
||||
shellCollisionCheck detid screenid pj w
|
||||
shellCollisionCheck pj w
|
||||
| RetiredProjectile <- pj ^. pjType
|
||||
, time <= -30
|
||||
= destroyProjectile (pj ^. pjScreenID) (_pjID pj) w
|
||||
@@ -96,7 +92,7 @@ shellCollisionCheck detid screenid pj w
|
||||
| time <= 0 = g
|
||||
| otherwise = w
|
||||
where
|
||||
g = explodeShell detid screenid pj w
|
||||
g = explodeShell pj w
|
||||
time = _pjTimer pj
|
||||
oldPos = _pjPos pj
|
||||
|
||||
@@ -184,20 +180,18 @@ decTimMvVel pj =
|
||||
)
|
||||
|
||||
explodeShell ::
|
||||
Maybe (NewInt ItmInt) ->
|
||||
Maybe (NewInt ItmInt) ->
|
||||
Projectile ->
|
||||
World ->
|
||||
World
|
||||
explodeShell mdetid screenid pj w =
|
||||
explodeShell pj w =
|
||||
w
|
||||
-- & cWorld . lWorld . projectiles . ix pjid . pjUpdates .~ [DestroyPU screenid 30]
|
||||
& cWorld . lWorld . projectiles . ix pjid . pjUpdates .~ []
|
||||
& cWorld . lWorld . projectiles . ix pjid . pjType .~ RetiredProjectile
|
||||
& usePayload (_pjPayload pj) (_pjPos pj) (_pjVel pj)
|
||||
& stopSoundFrom (ShellSound pjid)
|
||||
& updatedetonator
|
||||
where
|
||||
updatedetonator = fromMaybe id $ do
|
||||
detid <- mdetid
|
||||
detid <- pj ^. pjDetonatorID
|
||||
return $ pointerToItemID detid . itUse . uaParams . apProjectiles %~ delete pjid
|
||||
pjid = pj ^. pjID
|
||||
|
||||
Reference in New Issue
Block a user