Implement reloading of single external magazines

This commit is contained in:
2024-06-21 14:50:08 +01:00
parent 872e60438e
commit ecefba21d6
19 changed files with 157 additions and 340 deletions
+132 -130
View File
@@ -4,13 +4,13 @@ module Dodge.Item.Draw.SPic (
import Color
import qualified Data.Map.Strict as M
import Data.Maybe
--import Data.Maybe
import Dodge.Data.Item
import Dodge.Item.AmmoPosition
--import Dodge.Item.AmmoPosition
--import Dodge.Item.Weapon.FractionLoaded
import Geometry
import LensHelp
import qualified Linear.Quaternion as Q
--import qualified Linear.Quaternion as Q
import Picture
import Shape
import ShapePicture
@@ -64,76 +64,76 @@ leftItemSPic lt _ = case lt of
BLINKER -> defSPic
_ -> defSPic
ammoPosition :: Item -> HeldItemType -> AmmoPosition
ammoPosition itm hit = case hit of
FLATSHIELD -> NoAmmoPosition
FORCEFIELDGUN -> NoAmmoPosition
TORCH -> NoAmmoPosition
BANGSTICK i -> bangStickAmmoPos i itm
PISTOL -> Magazine (V3 5 2 0) lhs
MACHINEPISTOL -> Magazine (V3 5 2 0) lhs
AUTOPISTOL -> Magazine (V3 5 2 0) lhs
SMG -> Magazine (V3 7 (-2) 0) rhs
BANGCONE -> NoAmmoPosition
BLUNDERBUSS -> NoAmmoPosition
GRAPECANNON _ -> NoAmmoPosition
MINIGUNX _ -> NoAmmoPosition
VOLLEYGUN i -> volleygunAmmoPos i
MULTIGUN i -> multigunAmmoPos i
RIFLE -> Bullets [(V3 5 0 3, Q.axisAngle (V3 1 0 0) 0)]
REPEATER -> Magazine (V3 10 (-2) 0) rhs
AUTORIFLE -> Magazine (V3 10 (-2) 0) rhs
BURSTRIFLE -> Magazine (V3 10 (-2) 0) rhs
BANGROD -> Bullets [(V3 5 0 3, Q.axisAngle (V3 1 0 0) 0)]
ELEPHANTGUN -> Bullets [(V3 5 0 3, Q.axisAngle (V3 1 0 0) 0)]
AMR -> Magazine (V3 10 (-2) 0) rhs
AUTOAMR -> Magazine (V3 10 (-2) 0) rhs
SNIPERRIFLE -> Bullets [(V3 5 0 3, Q.axisAngle (V3 1 0 0) 0)]
MACHINEGUN -> Magazine (V3 10 (-2) 0) rhs
FLAMESPITTER -> NoAmmoPosition
FLAMETHROWER -> NoAmmoPosition
FLAMETORRENT -> NoAmmoPosition
FLAMEWALL -> NoAmmoPosition
BLOWTORCH -> NoAmmoPosition
SPARKGUN -> NoAmmoPosition
TESLAGUN -> NoAmmoPosition
LASGUN -> NoAmmoPosition
LASCIRCLE -> NoAmmoPosition
DUALBEAM -> NoAmmoPosition
LASWIDE _ -> NoAmmoPosition
--SONICGUN -> noPic baseSonicShape
TRACTORGUN -> NoAmmoPosition
LAUNCHER -> NoAmmoPosition
LAUNCHERX _ -> NoAmmoPosition
REMOTELAUNCHER -> NoAmmoPosition
POISONSPRAYER -> NoAmmoPosition
DRONELAUNCHER -> NoAmmoPosition
SHATTERGUN -> NoAmmoPosition
HELDDETECTOR _ -> NoAmmoPosition
KEYCARD _ -> NoAmmoPosition
where
lhs = Q.axisAngle (V3 1 0 0) pi
rhs = Q.axisAngle (V3 1 0 0) 0
--ammoPosition :: Item -> HeldItemType -> AmmoPosition
--ammoPosition itm hit = case hit of
-- FLATSHIELD -> NoAmmoPosition
-- FORCEFIELDGUN -> NoAmmoPosition
-- TORCH -> NoAmmoPosition
-- BANGSTICK i -> bangStickAmmoPos i itm
-- PISTOL -> Magazine (V3 5 2 0) lhs
-- MACHINEPISTOL -> Magazine (V3 5 2 0) lhs
-- AUTOPISTOL -> Magazine (V3 5 2 0) lhs
-- SMG -> Magazine (V3 7 (-2) 0) rhs
-- BANGCONE -> NoAmmoPosition
-- BLUNDERBUSS -> NoAmmoPosition
-- GRAPECANNON _ -> NoAmmoPosition
-- MINIGUNX _ -> NoAmmoPosition
-- VOLLEYGUN i -> volleygunAmmoPos i
-- MULTIGUN i -> multigunAmmoPos i
-- RIFLE -> Bullets [(V3 5 0 3, Q.axisAngle (V3 1 0 0) 0)]
-- REPEATER -> Magazine (V3 10 (-2) 0) rhs
-- AUTORIFLE -> Magazine (V3 10 (-2) 0) rhs
-- BURSTRIFLE -> Magazine (V3 10 (-2) 0) rhs
-- BANGROD -> Bullets [(V3 5 0 3, Q.axisAngle (V3 1 0 0) 0)]
-- ELEPHANTGUN -> Bullets [(V3 5 0 3, Q.axisAngle (V3 1 0 0) 0)]
-- AMR -> Magazine (V3 10 (-2) 0) rhs
-- AUTOAMR -> Magazine (V3 10 (-2) 0) rhs
-- SNIPERRIFLE -> Bullets [(V3 5 0 3, Q.axisAngle (V3 1 0 0) 0)]
-- MACHINEGUN -> Magazine (V3 10 (-2) 0) rhs
-- FLAMESPITTER -> NoAmmoPosition
-- FLAMETHROWER -> NoAmmoPosition
-- FLAMETORRENT -> NoAmmoPosition
-- FLAMEWALL -> NoAmmoPosition
-- BLOWTORCH -> NoAmmoPosition
-- SPARKGUN -> NoAmmoPosition
-- TESLAGUN -> NoAmmoPosition
-- LASGUN -> NoAmmoPosition
-- LASCIRCLE -> NoAmmoPosition
-- DUALBEAM -> NoAmmoPosition
-- LASWIDE _ -> NoAmmoPosition
-- --SONICGUN -> noPic baseSonicShape
-- TRACTORGUN -> NoAmmoPosition
-- LAUNCHER -> NoAmmoPosition
-- LAUNCHERX _ -> NoAmmoPosition
-- REMOTELAUNCHER -> NoAmmoPosition
-- POISONSPRAYER -> NoAmmoPosition
-- DRONELAUNCHER -> NoAmmoPosition
-- SHATTERGUN -> NoAmmoPosition
-- HELDDETECTOR _ -> NoAmmoPosition
-- KEYCARD _ -> NoAmmoPosition
-- where
-- lhs = Q.axisAngle (V3 1 0 0) pi
-- rhs = Q.axisAngle (V3 1 0 0) 0
bangStickAmmoPos :: Int -> Item -> AmmoPosition
bangStickAmmoPos _ itm =
Bullets
[(rotate3z a (V3 5 0 3), Q.axisAngle (V3 0 0 1) a)
| a <- map _mzRot (itm ^?! itUse . heldAim . aimMuzzles)]
--bangStickAmmoPos :: Int -> Item -> AmmoPosition
--bangStickAmmoPos _ itm =
-- Bullets
-- [(rotate3z a (V3 5 0 3), Q.axisAngle (V3 0 0 1) a)
-- | a <- map _mzRot (itm ^?! itUse . heldAim . aimMuzzles)]
volleygunAmmoPos :: Int -> AmmoPosition
volleygunAmmoPos i =
Bullets
[(V3 5 (f n) 3, Q.axisAngle (V3 1 0 0) 0) | n <- [0 .. i -1]]
where
f n = fromIntegral n * 5 - ((fromIntegral i - 1) * 2.5)
multigunAmmoPos :: Int -> AmmoPosition
multigunAmmoPos i =
Bullets
[(V3 5 (f n) 3, Q.axisAngle (V3 1 0 0) 0) | n <- [0 .. i -1]]
where
f n = fromIntegral n * 5 - ((fromIntegral i - 1) * 2.5)
--volleygunAmmoPos :: Int -> AmmoPosition
--volleygunAmmoPos i =
-- Bullets
-- [(V3 5 (f n) 3, Q.axisAngle (V3 1 0 0) 0) | n <- [0 .. i -1]]
-- where
-- f n = fromIntegral n * 5 - ((fromIntegral i - 1) * 2.5)
--
--multigunAmmoPos :: Int -> AmmoPosition
--multigunAmmoPos i =
-- Bullets
-- [(V3 5 (f n) 3, Q.axisAngle (V3 1 0 0) 0) | n <- [0 .. i -1]]
-- where
-- f n = fromIntegral n * 5 - ((fromIntegral i - 1) * 2.5)
--revolverAmmoPos :: AmmoPosition
--revolverAmmoPos =
@@ -254,39 +254,39 @@ baseRifleShape = colorSH red $ xCylinderST 3 25
-- ps <- fmap (take x) $ ammoPosition itm hit ^? amPosDirs
-- return $ foldMap (uncurry (drawBullet itm)) ps
-- why is this duplicated?
drawBullet :: Item -> Point3 -> Q.Quaternion Float -> Shape
drawBullet itm p q =
translateSH p $
overPosSH (Q.rotate q) $
colorSH
midcol
( upperPrismPolyTS 0.2 $
reverse
(rectNSWE 0.2 (- 0.2) (-1) 1)
)
<> tip
<> foot
where
midcol =
maybe
black
bulletEffectColor
(itm ^? itUse . heldConsumption . laAmmoType . amBullet . buEffect)
tip = fromMaybe mempty $ do
ebt <- itm ^? itUse . heldConsumption . laAmmoType . amBullet . buSpawn
return $
colorSH (bulletPayloadColor ebt) $
upperPrismPolyTS 0.2 $
reverse $
rectNSWE 0.2 (- 0.2) 1 2
foot = fromMaybe mempty $ do
ebt <- itm ^? itUse . heldConsumption . laAmmoType . amBullet . buTrajectory
return $
colorSH (bulletTrajColor ebt) $
upperPrismPolyTS 0.2 $
reverse $
rectNSWE 0.2 (- 0.2) (-2) (-1)
---- why is this duplicated?
--drawBullet :: Item -> Point3 -> Q.Quaternion Float -> Shape
--drawBullet itm p q =
-- translateSH p $
-- overPosSH (Q.rotate q) $
-- colorSH
-- midcol
-- ( upperPrismPolyTS 0.2 $
-- reverse
-- (rectNSWE 0.2 (- 0.2) (-1) 1)
-- )
-- <> tip
-- <> foot
-- where
-- midcol =
-- maybe
-- black
-- bulletEffectColor
-- (itm ^? itUse . heldConsumption . laAmmoType . amBullet . buEffect)
-- tip = fromMaybe mempty $ do
-- ebt <- itm ^? itUse . heldConsumption . laAmmoType . amBullet . buSpawn
-- return $
-- colorSH (bulletPayloadColor ebt) $
-- upperPrismPolyTS 0.2 $
-- reverse $
-- rectNSWE 0.2 (- 0.2) 1 2
-- foot = fromMaybe mempty $ do
-- ebt <- itm ^? itUse . heldConsumption . laAmmoType . amBullet . buTrajectory
-- return $
-- colorSH (bulletTrajColor ebt) $
-- upperPrismPolyTS 0.2 $
-- reverse $
-- rectNSWE 0.2 (- 0.2) (-2) (-1)
addTinClip :: Item -> Shape
addTinClip _ = mempty
@@ -333,33 +333,33 @@ addTinClip _ = mempty
-- reverse $
-- rectNSWE 0 (- y) (-2) (-1)
bulletEffectColor :: BulletEffect -> Color
bulletEffectColor x = case x of
DestroyBullet -> black
BounceBullet -> mixColors 0.5 0.5 black yellow
PenetrateBullet -> mixColors 0.5 0.5 black blue
--bulletEffectColor :: BulletEffect -> Color
--bulletEffectColor x = case x of
-- DestroyBullet -> black
-- BounceBullet -> mixColors 0.5 0.5 black yellow
-- PenetrateBullet -> mixColors 0.5 0.5 black blue
bulletTrajColor :: BulletTrajectory -> Color
bulletTrajColor x = case x of
BasicBulletTrajectory -> black
BezierTrajectory{} -> chartreuse
FlechetteTrajectory{} -> white
MagnetTrajectory{} -> yellow
--bulletTrajColor :: BulletTrajectory -> Color
--bulletTrajColor x = case x of
-- BasicBulletTrajectory -> black
-- BezierTrajectory{} -> chartreuse
-- FlechetteTrajectory{} -> white
-- MagnetTrajectory{} -> yellow
bulletPayloadColor :: BulletSpawn -> Color
bulletPayloadColor x = case x of
BulBall y -> energyBallColor y
BulSpark -> black
BulFlak -> chartreuse
BulFrag -> magenta
BulGas -> green
--bulletPayloadColor :: BulletSpawn -> Color
--bulletPayloadColor x = case x of
-- BulBall y -> energyBallColor y
-- BulSpark -> black
-- BulFlak -> chartreuse
-- BulFrag -> magenta
-- BulGas -> green
energyBallColor :: EnergyBallType -> Color
energyBallColor ebt = case ebt of
IncBall -> orange
TeslaBall -> cyan
ConcBall -> white
FlashBall -> yellow
--energyBallColor :: EnergyBallType -> Color
--energyBallColor ebt = case ebt of
-- IncBall -> orange
-- TeslaBall -> cyan
-- ConcBall -> white
-- FlashBall -> yellow
volleyGunShape :: Int -> Shape
volleyGunShape i =
@@ -404,7 +404,8 @@ baseSMGShape :: Shape
baseSMGShape = colorSH green $ xCylinderST 3 20
flamerPic :: Item -> SPic
flamerPic it =
--flamerPic it =
flamerPic _ =
( colorSH yellow $
translateSHxy tx ty (upperPrismPolyST tz $ polyCirc 3 r)
<> xCylinderST 5 18
@@ -445,7 +446,8 @@ teslaGunPic =
xb = 9
lasGunPic :: Item -> SPic
lasGunPic it =
--lasGunPic it =
lasGunPic _ =
( colorSH blue $
upperBoxST 4 (rectNESW 3 30 1 0)
<> upperBoxSU 4 (rectNESW (-1) 30 (-3) 0)