Cleanup projectile update
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
@@ -9,8 +9,6 @@ module Dodge.Data.Item.Use.Consumption.Ammo (
|
||||
module Dodge.Data.Payload,
|
||||
) where
|
||||
|
||||
import Dodge.Data.Item.Location
|
||||
import NewInt
|
||||
import Control.Lens
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
@@ -22,9 +20,6 @@ data ProjectileUpdate
|
||||
| StartSpinPU {_pjuTime :: Int, _pjuCID :: Int, _pjuSpinAmound :: Int}
|
||||
| RemoteDirectionPU {_pjuStart :: Int, _pjuEnd :: Int}
|
||||
| ReduceSpinPU {_pjuReduceSpin :: Float}
|
||||
-- | DestroyPU {_pjuScreenID :: Maybe (NewInt ItmInt)
|
||||
-- ,_pjuTimer :: Int}
|
||||
-- | TimePU
|
||||
| ApplyGravityPU
|
||||
deriving (Show, Eq, Ord, Read) --Generic, Flat)
|
||||
|
||||
|
||||
@@ -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