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
+33 -80
View File
@@ -1,6 +1,6 @@
module Dodge.Projectile.Create
( fireTrackingShell
) where
module Dodge.Projectile.Create (
fireTrackingShell,
) where
import Data.Maybe
import Dodge.Data.World
@@ -9,88 +9,41 @@ import qualified IntMapHelp as IM
import LensHelp
-- assumes the mscreen is in your inventory
fireTrackingShell :: Maybe Item -> Item -> Muzzle -> Item -> Creature -> World -> World
fireTrackingShell mscreen ammoitem muz it cr 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 =
[ 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)
]
-- , _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)
-- ]
fireTrackingShell :: Maybe Item -> AmmoParams -> Muzzle -> Item -> Creature -> World -> World
fireTrackingShell mscreen aparams muz it cr w = w
& updatescreen
& cWorld . lWorld . projectiles . at i
?~ Shell
{ _prjPos = pos
, _prjZ = 20
, _prjStartPos = pos
, _prjVel = rotateV dir (V2 1 0)
, _prjDraw = maybe DrawShell (const DrawRemoteShell) mscreen
, _prjID = i
, _prjAcc = rotateV dir (V2 3 0)
, _prjDir = dir
, _prjSpin = 0
, _prjPayload = _ampPayload aparams
, _prjTimer = 350
, _prjUpdates =
[ PJRemoteShellCollisionCheck (mscreen ^? _Just . itID) --Just screenid)
, PJDecTimMvVel
, PJSpin 335 (_crID cr) (_shellSpinAmount params)
, PJRemoteSetDirection (350 - thrustdelay) 0 (mscreen ^? _Just . itID)
, PJThrust (350 - thrustdelay) 0
, PJReduceSpin (1 - fromIntegral (_shellSpinDrag params) * 2 / 200)
]
}
where
spinamount = _shellSpinAmount params
thrustdelay = _shellThrustDelay params
spindrag = _shellSpinDrag params
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
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)