Cleanup projectile creation
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
All good (620 modules, at 13:53:54)
|
All good (620 modules, at 14:13:42)
|
||||||
|
|||||||
+4
-11
@@ -504,23 +504,16 @@ createProjectile magtree muz itm cr = fromMaybe failsound $ do
|
|||||||
magid <- magtree ^? ldtValue . itLocation . ilInvID
|
magid <- magtree ^? ldtValue . itLocation . ilInvID
|
||||||
ammoitem <- cr ^? crInv . ix magid
|
ammoitem <- cr ^? crInv . ix magid
|
||||||
let mscreen = lookup RemoteScreenLink (magtree ^. ldtLeft)
|
let mscreen = lookup RemoteScreenLink (magtree ^. ldtLeft)
|
||||||
-- matype <- ammoitem ^? itUse . amagType
|
|
||||||
-- guard $ matype == ProjectileAmmo
|
|
||||||
j <- ammoitem ^? itLocation . ilInvID
|
j <- ammoitem ^? itLocation . ilInvID
|
||||||
return $ fireTrackingShell (mscreen ^? _Just . ldtValue) ammoitem muz itm cr . extrafuncs j
|
return $ fireTrackingShell (mscreen ^? _Just . ldtValue) ammoitem muz itm cr
|
||||||
-- pt <- ammoitem ^? itUse . amagParams . ampPjCreation
|
. startthesound
|
||||||
-- return $ case mscreen of
|
. useammo j
|
||||||
-- Nothing -> fireShell ammoitem muz itm cr . extrafuncs j
|
|
||||||
-- Just stree -> fireTrackingShell
|
|
||||||
-- (stree ^? ldtValue) ammoitem muz itm cr
|
|
||||||
-- . extrafuncs j
|
|
||||||
where
|
where
|
||||||
--extrafuncs j = cancelanyreloading . startthesound . useammo j
|
|
||||||
extrafuncs j = startthesound . useammo j
|
|
||||||
useammo j = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix j . itUse . amagLoadStatus . iaLoaded -~ 1
|
useammo j = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix j . itUse . amagLoadStatus . iaLoaded -~ 1
|
||||||
|
|
||||||
-- the sound should be moved to the projectile firing
|
-- the sound should be moved to the projectile firing
|
||||||
startthesound = soundMultiFrom [CrWeaponSound (_crID cr) j | j <- [0..3]] (_crPos cr) tap4S Nothing
|
startthesound = soundMultiFrom [CrWeaponSound (_crID cr) j | j <- [0..3]] (_crPos cr) tap4S Nothing
|
||||||
|
-- failsound = soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing
|
||||||
failsound w' = case w' ^? input . mouseButtons . ix SDL.ButtonLeft of
|
failsound w' = case w' ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||||
Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w'
|
Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w'
|
||||||
_ -> soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w'
|
_ -> soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w'
|
||||||
|
|||||||
@@ -1,44 +1,18 @@
|
|||||||
module Dodge.Projectile.Create
|
module Dodge.Projectile.Create
|
||||||
( fireShell
|
( fireTrackingShell
|
||||||
, fireTrackingShell
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
--import Dodge.SoundLogic
|
|
||||||
--import Control.Monad
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
import Geometry
|
import Geometry
|
||||||
import qualified IntMapHelp as IM
|
import qualified IntMapHelp as IM
|
||||||
import LensHelp
|
import LensHelp
|
||||||
--import qualified SDL
|
|
||||||
|
|
||||||
|
-- assumes the mscreen is in your inventory
|
||||||
fireShell :: Item -> Muzzle -> Item -> Creature -> World -> World
|
fireTrackingShell :: Maybe Item -> Item -> Muzzle -> Item -> Creature -> World -> World
|
||||||
fireShell ammoitem muz it cr =
|
fireTrackingShell mscreen ammoitem muz it cr w = fromMaybe w $ do
|
||||||
makeShell
|
|
||||||
Nothing
|
|
||||||
ammoitem
|
|
||||||
muz
|
|
||||||
cr
|
|
||||||
[ PJRemoteShellCollisionCheck Nothing
|
|
||||||
, PJDecTimMvVel
|
|
||||||
, PJSpin 335 (_crID cr) spinamount
|
|
||||||
, PJRemoteSetDirection (350 - thrustdelay) 0 Nothing
|
|
||||||
, PJThrust (350 - thrustdelay) 0
|
|
||||||
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
|
|
||||||
]
|
|
||||||
where
|
|
||||||
params = _itParams it
|
|
||||||
spindrag = _shellSpinDrag params
|
|
||||||
spinamount = _shellSpinAmount params
|
|
||||||
thrustdelay = _shellThrustDelay params
|
|
||||||
|
|
||||||
-- rather than screen invid why not use an item location?
|
|
||||||
makeShell :: Maybe Int -> Item -> Muzzle -> Creature -> [ProjectileUpdate] -> World -> World
|
|
||||||
makeShell mscreeninvid ammoitem muz cr theupdate w = fromMaybe w $ do
|
|
||||||
aparams <- ammoitem ^? itUse . amagParams
|
aparams <- ammoitem ^? itUse . amagParams
|
||||||
return $
|
return $ w & cWorld . lWorld . projectiles . at i
|
||||||
w & cWorld . lWorld . projectiles . at i
|
|
||||||
?~ Shell
|
?~ Shell
|
||||||
{ _prjPos = pos
|
{ _prjPos = pos
|
||||||
, _prjZ = 20
|
, _prjZ = 20
|
||||||
@@ -51,28 +25,7 @@ makeShell mscreeninvid ammoitem muz cr theupdate w = fromMaybe w $ do
|
|||||||
, _prjSpin = 0
|
, _prjSpin = 0
|
||||||
, _prjPayload = _ampPayload aparams
|
, _prjPayload = _ampPayload aparams
|
||||||
, _prjTimer = 350
|
, _prjTimer = 350
|
||||||
, _prjUpdates = theupdate
|
, _prjUpdates =
|
||||||
-- , _prjMITID = Just $ _itID it
|
|
||||||
}
|
|
||||||
& updatescreen
|
|
||||||
where
|
|
||||||
updatescreen = fromMaybe id $ do
|
|
||||||
screeninvid <- mscreeninvid
|
|
||||||
return $ cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix screeninvid
|
|
||||||
. itUse . atLinkedProjectile ?~ i
|
|
||||||
i = IM.newKey $ w ^. cWorld . lWorld . projectiles -- _props (_cWorld w)
|
|
||||||
dir = _crDir cr + _mzRot muz
|
|
||||||
pos = _crPos cr +.+ rotateV dir (_mzPos muz)
|
|
||||||
|
|
||||||
--am = _heldConsumption $ _itUse it
|
|
||||||
|
|
||||||
-- assumes the mscreen is in your inventory
|
|
||||||
fireTrackingShell :: Maybe Item -> Item -> Muzzle -> Item -> Creature -> World -> World
|
|
||||||
fireTrackingShell mscreen ammoitem muz it cr = makeShell
|
|
||||||
(mscreen ^? _Just . itLocation . ilInvID) -- Just screeninvid)
|
|
||||||
ammoitem
|
|
||||||
muz
|
|
||||||
cr
|
|
||||||
[ PJRemoteShellCollisionCheck (mscreen ^? _Just . itID) --Just screenid)
|
[ PJRemoteShellCollisionCheck (mscreen ^? _Just . itID) --Just screenid)
|
||||||
, PJDecTimMvVel
|
, PJDecTimMvVel
|
||||||
, PJSpin 335 (_crID cr) spinamount
|
, PJSpin 335 (_crID cr) spinamount
|
||||||
@@ -80,8 +33,64 @@ fireTrackingShell mscreen ammoitem muz it cr = makeShell
|
|||||||
, PJThrust (350 - thrustdelay) 0
|
, PJThrust (350 - thrustdelay) 0
|
||||||
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
|
, PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
-- , _prjMITID = Just $ _itID it
|
||||||
|
}
|
||||||
|
& updatescreen
|
||||||
|
|
||||||
|
-- makeShell
|
||||||
|
-- (mscreen ^? _Just . itLocation . ilInvID) -- Just screeninvid)
|
||||||
|
-- ammoitem
|
||||||
|
-- muz
|
||||||
|
-- cr
|
||||||
|
-- [ PJRemoteShellCollisionCheck (mscreen ^? _Just . itID) --Just screenid)
|
||||||
|
-- , PJDecTimMvVel
|
||||||
|
-- , PJSpin 335 (_crID cr) spinamount
|
||||||
|
-- , PJRemoteSetDirection (350 - thrustdelay) 0 (mscreen ^? _Just . itID)
|
||||||
|
-- , PJThrust (350 - thrustdelay) 0
|
||||||
|
-- , PJReduceSpin (1 - fromIntegral spindrag * 2 / 200)
|
||||||
|
-- ]
|
||||||
where
|
where
|
||||||
spinamount = _shellSpinAmount params
|
spinamount = _shellSpinAmount params
|
||||||
thrustdelay = _shellThrustDelay params
|
thrustdelay = _shellThrustDelay params
|
||||||
spindrag = _shellSpinDrag params
|
spindrag = _shellSpinDrag params
|
||||||
params = _itParams it
|
params = _itParams it
|
||||||
|
updatescreen = fromMaybe id $ do
|
||||||
|
screeninvid <- mscreen ^? _Just . itLocation . ilInvID
|
||||||
|
return $ cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix screeninvid
|
||||||
|
. itUse . atLinkedProjectile ?~ i
|
||||||
|
i = IM.newKey $ w ^. cWorld . lWorld . projectiles -- _props (_cWorld w)
|
||||||
|
dir = _crDir cr + _mzRot muz
|
||||||
|
pos = _crPos cr +.+ rotateV dir (_mzPos muz)
|
||||||
|
|
||||||
|
---- rather than screen invid why not use an item location?
|
||||||
|
--makeShell :: Maybe Int -> Item -> Muzzle -> Creature -> [ProjectileUpdate] -> World -> World
|
||||||
|
--makeShell mscreeninvid ammoitem muz cr theupdate w = fromMaybe w $ do
|
||||||
|
-- aparams <- ammoitem ^? itUse . amagParams
|
||||||
|
-- return $
|
||||||
|
-- w & cWorld . lWorld . projectiles . at i
|
||||||
|
-- ?~ Shell
|
||||||
|
-- { _prjPos = pos
|
||||||
|
-- , _prjZ = 20
|
||||||
|
-- , _prjStartPos = pos
|
||||||
|
-- , _prjVel = rotateV dir (V2 1 0)
|
||||||
|
-- , _prjDraw = DrawShell
|
||||||
|
-- , _prjID = i
|
||||||
|
-- , _prjAcc = rotateV dir (V2 3 0)
|
||||||
|
-- , _prjDir = dir
|
||||||
|
-- , _prjSpin = 0
|
||||||
|
-- , _prjPayload = _ampPayload aparams
|
||||||
|
-- , _prjTimer = 350
|
||||||
|
-- , _prjUpdates = theupdate
|
||||||
|
---- , _prjMITID = Just $ _itID it
|
||||||
|
-- }
|
||||||
|
-- & updatescreen
|
||||||
|
-- where
|
||||||
|
-- updatescreen = fromMaybe id $ do
|
||||||
|
-- screeninvid <- mscreeninvid
|
||||||
|
-- return $ cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix screeninvid
|
||||||
|
-- . itUse . atLinkedProjectile ?~ i
|
||||||
|
-- i = IM.newKey $ w ^. cWorld . lWorld . projectiles -- _props (_cWorld w)
|
||||||
|
-- dir = _crDir cr + _mzRot muz
|
||||||
|
-- pos = _crPos cr +.+ rotateV dir (_mzPos muz)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user