Cleanup projectile creation

This commit is contained in:
2024-09-27 14:14:58 +01:00
parent 21e49ddefc
commit dd6cbc0bfb
3 changed files with 67 additions and 65 deletions
+4 -11
View File
@@ -504,23 +504,16 @@ createProjectile magtree muz itm cr = fromMaybe failsound $ do
magid <- magtree ^? ldtValue . itLocation . ilInvID
ammoitem <- cr ^? crInv . ix magid
let mscreen = lookup RemoteScreenLink (magtree ^. ldtLeft)
-- matype <- ammoitem ^? itUse . amagType
-- guard $ matype == ProjectileAmmo
j <- ammoitem ^? itLocation . ilInvID
return $ fireTrackingShell (mscreen ^? _Just . ldtValue) ammoitem muz itm cr . extrafuncs j
-- pt <- ammoitem ^? itUse . amagParams . ampPjCreation
-- return $ case mscreen of
-- Nothing -> fireShell ammoitem muz itm cr . extrafuncs j
-- Just stree -> fireTrackingShell
-- (stree ^? ldtValue) ammoitem muz itm cr
-- . extrafuncs j
return $ fireTrackingShell (mscreen ^? _Just . ldtValue) ammoitem muz itm cr
. startthesound
. useammo j
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
-- the sound should be moved to the projectile firing
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
Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w'
_ -> soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w'