Start simplifying projectile update
This commit is contained in:
@@ -5,6 +5,7 @@ module Dodge.Projectile.Update (
|
||||
updateProjectile,
|
||||
) where
|
||||
|
||||
import Control.Monad
|
||||
import Data.Foldable
|
||||
import Data.List (delete, deleteBy)
|
||||
import Data.Maybe
|
||||
@@ -34,18 +35,15 @@ updateProjectile pj w =
|
||||
|
||||
upProjectile :: Projectile -> ProjectileUpdate -> World -> World
|
||||
upProjectile pj = \case
|
||||
ThrustPU st et
|
||||
| act st et -> doThrust pj (pj ^? pjType . rkSmoke . _Just)
|
||||
| otherwise -> id
|
||||
StartSpinPU t cid spinamount
|
||||
| time == t -> trySpinByCID cid spinamount pj
|
||||
| otherwise -> id
|
||||
RemoteDirectionPU st et
|
||||
| act st et -> pjRemoteSetDirection (pj ^? pjType . rkHoming) pj
|
||||
| otherwise -> id
|
||||
-- RemoteDirectionPU st et
|
||||
-- | act st et -> pjRemoteSetDirection (pj ^? pjType . rkHoming) pj
|
||||
-- | otherwise -> id
|
||||
where
|
||||
time = _pjTimer pj
|
||||
act st et = time <= st && time >= et
|
||||
-- act st et = time <= st && time >= et
|
||||
|
||||
doGravityPU :: Projectile -> World -> World
|
||||
doGravityPU pj
|
||||
@@ -143,6 +141,12 @@ destroyProjectile mitid pjid w =
|
||||
loc <- w ^? cWorld . lWorld . itemLocations . ix itid
|
||||
return $ pointerToItemLocation loc . itUse . uaParams . apProjectiles %~ delete pjid
|
||||
|
||||
tryThrust :: Projectile -> World -> World
|
||||
tryThrust pj = fromMaybe id $ do
|
||||
Rocket y x <- pj ^? pjType
|
||||
guard $ pj ^. pjTimer <= 330 && pj ^. pjTimer >= 0
|
||||
return $ doThrust pj x . pjRemoteSetDirection (Just y) pj
|
||||
|
||||
doThrust :: Projectile -> Maybe RocketSmoke -> World -> World
|
||||
doThrust pj smoke w =
|
||||
w
|
||||
@@ -184,7 +188,7 @@ trySpinByCID cid i pj w =
|
||||
& cWorld . lWorld . projectiles . ix pjid . pjUpdates %~ deleteBy f (StartSpinPU 0 0 0)
|
||||
where
|
||||
f _ StartSpinPU{} = True
|
||||
f _ _ = False
|
||||
-- f _ _ = False
|
||||
pjid = _pjID pj
|
||||
dir = argV $ _pjVel pj
|
||||
newSpin = case w ^? cWorld . lWorld . creatures . ix cid of
|
||||
@@ -237,6 +241,7 @@ moveProjectile pj w
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos +~ _pjVel pj
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir
|
||||
+~ (_pjSpin pj * _pjSpinFactor pj)
|
||||
& tryThrust pj
|
||||
|
||||
explodeShell ::
|
||||
Projectile ->
|
||||
|
||||
Reference in New Issue
Block a user