This commit is contained in:
2024-09-27 21:55:17 +01:00
parent dd6cbc0bfb
commit 6c3d0d5def
21 changed files with 232 additions and 333 deletions
+31 -23
View File
@@ -1,33 +1,30 @@
{-# OPTIONS_GHC -Wno-unused-imports #-}
module Dodge.Projectile.Update where
--{-# OPTIONS_GHC -Wno-unused-imports #-}
module Dodge.Projectile.Update
( updateProjectile
) where
import Control.Lens
import qualified Data.Map.Strict as M
import Data.Maybe
import Dodge.Base
import Dodge.Data.World
import Dodge.EnergyBall
import Dodge.Item.Location
import Dodge.Item.Weapon.Launcher
import Dodge.Item.Weapon.Remote
import Dodge.Item.Weapon.Shell
import Dodge.Item.Weapon.TriggerType
import Dodge.Movement.Turn
import Dodge.Payload
import Dodge.SoundLogic
import Dodge.SoundLogic.LoadSound
import Dodge.WorldEvent.Cloud
import Geometry
import qualified IntMapHelp as IM
import RandomHelp
import qualified SDL
updateProjectile :: Proj -> World -> World
updateProjectile pj = case pj of
Shell{} -> upsProjectile pj
updateProjectile :: Projectile -> World -> World
updateProjectile pj w' = foldr (`upProjectile` pj) w' (_prjUpdates pj)
--updateProjectile pj = case pj of
-- Shell{} -> upsProjectile pj
--
--upsProjectile :: Projectile -> World -> World
--upsProjectile pj w' = foldr (`upProjectile` pj) w' (_prjUpdates pj)
shellCollisionCheck :: (Proj -> World -> World) -> Proj -> World -> World
shellCollisionCheck :: (Projectile -> World -> World) -> Projectile -> World -> World
shellCollisionCheck doExplode pj w
| time > 330 && circOnSomeWall oldPos 4 w = doExplode pj w
| time <= 330 && anythingHitCirc 2 oldPos newPos w = doExplode pj w
@@ -39,7 +36,7 @@ shellCollisionCheck doExplode pj w
vel = _prjVel pj
newPos = oldPos +.+ vel
remoteShellCollisionCheck :: Maybe Int -> Proj -> World -> World
remoteShellCollisionCheck :: Maybe Int -> Projectile -> World -> World
remoteShellCollisionCheck mscreenid = shellCollisionCheck
$ \pj -> explodeRemoteRocket mscreenid (_prjID pj)
@@ -49,10 +46,8 @@ remoteShellCollisionCheck mscreenid = shellCollisionCheck
-- . stopSoundFrom (ShellSound (_prjID pj))
-- . (cWorld . lWorld . projectiles %~ IM.delete (_prjID pj))
upsProjectile :: Proj -> World -> World
upsProjectile pj w' = foldr (`upProjectile` pj) w' (_prjUpdates pj)
upProjectile :: ProjectileUpdate -> Proj -> World -> World
upProjectile :: ProjectileUpdate -> Projectile -> World -> World
upProjectile pu pj = case pu of
PJRemoteShellCollisionCheck mscreenid -> remoteShellCollisionCheck mscreenid pj
-- PJShellCollisionCheck -> plainShellCollisionCheck pj
@@ -91,7 +86,7 @@ retireRemoteProj mitid pjid w = w & cWorld . lWorld . projectiles %~ IM.delete p
guard $ itm == pjid
return $ pointerToItemLocation loc . itUse . atLinkedProjectile .~ Nothing
doThrust :: Proj -> World -> World
doThrust :: Projectile -> World -> World
doThrust pj w =
w
& randGen .~ g
@@ -117,7 +112,7 @@ trySpinByCID ::
Int ->
-- | Spin amount
Int ->
Proj ->
Projectile ->
World ->
World
trySpinByCID cid i pj w = w & cWorld . lWorld . projectiles . ix pjid . prjSpin .~ newSpin
@@ -144,7 +139,7 @@ trySpinByCID cid i pj w = w & cWorld . lWorld . projectiles . ix pjid . prjSpin
-- --itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid
-- note this only allows YOU to remotely track projectiles
pjRemoteSetDirection :: Maybe Int -> Proj -> World -> World
pjRemoteSetDirection :: Maybe Int -> Projectile -> World -> World
pjRemoteSetDirection mscreenid pj w = fromMaybe w $ do
screenid <- mscreenid
let newdir
@@ -169,5 +164,18 @@ pjRemoteSetDirection mscreenid pj w = fromMaybe w $ do
-- (argV $ _prjAcc pj)
-- --itPoint = pointerToItemLocation $ w ^?! cWorld . lWorld . itemLocations . ix itid
reduceSpinBy :: Float -> Proj -> World -> World
reduceSpinBy :: Float -> Projectile -> World -> World
reduceSpinBy x pj = cWorld . lWorld . projectiles . ix (_prjID pj) . prjSpin *~ x
decTimMvVel :: Projectile -> World -> World
decTimMvVel pj =
cWorld . lWorld . projectiles . ix pjid
%~ ( (prjTimer -~ 1)
. (prjPos %~ (+.+ vel))
. (prjAcc %~ rotateV rot)
)
where
rot = _prjSpin pj
vel = _prjVel pj
pjid = _prjID pj