Cleanup projectile update

This commit is contained in:
2024-12-28 22:07:05 +00:00
parent 30be7b0983
commit ad7be9152a
3 changed files with 58 additions and 73 deletions
+1 -6
View File
@@ -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)
+5 -11
View File
@@ -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