Implement magazine drawing using ammo positioning function
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
module Dodge.Item.AmmoPosition where
|
||||
|
||||
import Linear.Quaternion (Quaternion (..))
|
||||
import Control.Lens
|
||||
import Geometry.Data
|
||||
|
||||
data AmmoPosition
|
||||
= Magazine {_amposPos :: Point3, _amposDir :: Quaternion Float}
|
||||
| Bullets {_amPosDirs :: [(Point3,Point3)]}
|
||||
| NoAmmoPosition
|
||||
makeLenses ''AmmoPosition
|
||||
+86
-50
@@ -1,5 +1,7 @@
|
||||
module Dodge.Item.Draw.SPic where
|
||||
|
||||
import qualified Linear.Quaternion as Q
|
||||
import Dodge.Item.AmmoPosition
|
||||
import Color
|
||||
import Data.Maybe
|
||||
import Dodge.Data.Item
|
||||
@@ -56,55 +58,58 @@ leftItemSPic lt _ = case lt of
|
||||
BLINKER -> defSPic
|
||||
_ -> defSPic
|
||||
|
||||
magazinePosition :: HeldItemType -> Maybe (Point3, Point3)
|
||||
magazinePosition hit = case hit of
|
||||
FLATSHIELD -> Nothing
|
||||
FORCEFIELDGUN -> Nothing
|
||||
TORCH -> Nothing
|
||||
BANGSTICK _ -> Nothing
|
||||
PISTOL -> Just (V3 5 2 0, V3 0 1 0)
|
||||
REVOLVER -> Nothing
|
||||
REVOLVERX _ -> Nothing
|
||||
MACHINEPISTOL -> Just (V3 5 2 0, V3 0 1 0)
|
||||
AUTOPISTOL -> Just (V3 5 2 0, V3 0 1 0)
|
||||
SMG -> Just (V3 7 (-2) 0 , V3 0 0 0)
|
||||
BANGCONE -> Nothing
|
||||
BLUNDERBUSS -> Nothing
|
||||
GRAPECANNON _ -> Nothing
|
||||
MINIGUNX _ -> Nothing
|
||||
VOLLEYGUN _ -> Nothing
|
||||
RIFLE -> Nothing
|
||||
REPEATER -> Just (V3 10 (-2) 0 , V3 0 0 0)
|
||||
AUTORIFLE -> Just (V3 10 (-2) 0 , V3 0 0 0)
|
||||
BURSTRIFLE -> Just (V3 10 (-2) 0 , V3 0 0 0)
|
||||
BANGROD -> Nothing
|
||||
ELEPHANTGUN -> Nothing
|
||||
AMR -> Just (V3 10 (-2) 0 , V3 0 0 0)
|
||||
AUTOAMR -> Just (V3 10 (-2) 0 , V3 0 0 0)
|
||||
SNIPERRIFLE -> Nothing
|
||||
MACHINEGUN -> Just (V3 10 (-2) 0 , V3 0 0 0)
|
||||
FLAMESPITTER -> Nothing
|
||||
FLAMETHROWER -> Nothing
|
||||
FLAMETORRENT -> Nothing
|
||||
FLAMEWALL -> Nothing
|
||||
BLOWTORCH -> Nothing
|
||||
SPARKGUN -> Nothing
|
||||
TESLAGUN -> Nothing
|
||||
LASGUN -> Nothing
|
||||
LASCIRCLE -> Nothing
|
||||
DUALBEAM -> Nothing
|
||||
LASWIDE _ -> Nothing
|
||||
ammoPosition :: HeldItemType -> AmmoPosition
|
||||
ammoPosition hit = case hit of
|
||||
FLATSHIELD -> NoAmmoPosition
|
||||
FORCEFIELDGUN -> NoAmmoPosition
|
||||
TORCH -> NoAmmoPosition
|
||||
BANGSTICK _ -> NoAmmoPosition
|
||||
PISTOL -> Magazine (V3 5 2 0) lhs
|
||||
REVOLVER -> NoAmmoPosition
|
||||
REVOLVERX _ -> NoAmmoPosition
|
||||
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 _ -> NoAmmoPosition
|
||||
RIFLE -> NoAmmoPosition
|
||||
REPEATER -> Magazine (V3 10 (-2) 0 ) rhs
|
||||
AUTORIFLE -> Magazine (V3 10 (-2) 0 ) rhs
|
||||
BURSTRIFLE -> Magazine (V3 10 (-2) 0 ) rhs
|
||||
BANGROD -> NoAmmoPosition
|
||||
ELEPHANTGUN -> NoAmmoPosition
|
||||
AMR -> Magazine (V3 10 (-2) 0 ) rhs
|
||||
AUTOAMR -> Magazine (V3 10 (-2) 0 ) rhs
|
||||
SNIPERRIFLE -> NoAmmoPosition
|
||||
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 -> Nothing
|
||||
LAUNCHER -> Nothing
|
||||
LAUNCHERX _ -> Nothing
|
||||
REMOTELAUNCHER -> Nothing
|
||||
POISONSPRAYER -> Nothing
|
||||
DRONELAUNCHER -> Nothing
|
||||
SHATTERGUN -> Nothing
|
||||
HELDDETECTOR _ -> Nothing
|
||||
KEYCARD _ -> Nothing
|
||||
BINOCULARS -> Nothing
|
||||
TRACTORGUN -> NoAmmoPosition
|
||||
LAUNCHER -> NoAmmoPosition
|
||||
LAUNCHERX _ -> NoAmmoPosition
|
||||
REMOTELAUNCHER -> NoAmmoPosition
|
||||
POISONSPRAYER -> NoAmmoPosition
|
||||
DRONELAUNCHER -> NoAmmoPosition
|
||||
SHATTERGUN -> NoAmmoPosition
|
||||
HELDDETECTOR _ -> NoAmmoPosition
|
||||
KEYCARD _ -> NoAmmoPosition
|
||||
BINOCULARS -> NoAmmoPosition
|
||||
where
|
||||
lhs = Q.axisAngle (V3 0 0 1) pi
|
||||
rhs = Q.axisAngle (V3 0 1 0) pi
|
||||
|
||||
heldItemSPic :: HeldItemType -> Item -> SPic
|
||||
heldItemSPic ht it = case ht of
|
||||
@@ -112,12 +117,14 @@ heldItemSPic ht it = case ht of
|
||||
FORCEFIELDGUN -> defSPic
|
||||
TORCH -> noPic torchShape
|
||||
BANGSTICK i -> noPic $ baseStickShapeX it i <> stickClip it
|
||||
PISTOL -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it
|
||||
--PISTOL -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it
|
||||
PISTOL -> noPic $ baseStickShape <> addTinClip it
|
||||
REVOLVER -> noPic $ baseStickShape <> revolverClip it
|
||||
REVOLVERX _ -> noPic $ baseStickShape <> revolverClip it
|
||||
MACHINEPISTOL -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it
|
||||
AUTOPISTOL -> noPic $ baseStickShape <> makeTinClipAt pi (V3 5 2 0) it
|
||||
SMG -> noPic (baseSMGShape <> makeTinClipAt 0 (V3 7 (-2) 0) it)
|
||||
--SMG -> noPic (baseSMGShape <> makeTinClipAt 0 (V3 7 (-2) 0) it)
|
||||
SMG -> noPic $ baseSMGShape <> addTinClip it
|
||||
BANGCONE ->
|
||||
noPic $
|
||||
colorSH cyan $
|
||||
@@ -237,6 +244,35 @@ makeSingleClipAt p it = case it ^? itUse . heldConsumption . laLoaded of
|
||||
Just 0 -> mempty
|
||||
_ -> translateSH p $ upperPrismPoly 1 $ square 1.5
|
||||
|
||||
addTinClip :: Item -> Shape
|
||||
addTinClip itm = fromMaybe mempty $ do
|
||||
hit <- itm ^? itType . iyBase . ibtHeld
|
||||
let ap = ammoPosition hit
|
||||
p <- ap ^? amposPos
|
||||
d <- ap ^? amposDir
|
||||
return $ translateSH p $ overPosSH (Q.rotate d) $ makeTinClip itm
|
||||
|
||||
makeTinClip :: Item -> Shape
|
||||
makeTinClip it =
|
||||
colorSH midcol (upperPrismPoly 1 (
|
||||
reverse $
|
||||
rectNSWE 0 (- y) (-2) 2)) <> translateSHz (-0.05) (tips <> tails)
|
||||
where
|
||||
midcol = maybe black bulletEffectColor
|
||||
(it ^? itUse . heldConsumption . laAmmoType . amBullet . buEffect)
|
||||
y = fromIntegral y' * 0.3
|
||||
y' = fromMaybe 0 $ it ^? itUse . heldConsumption . laLoaded
|
||||
tips = fromMaybe mempty $ do
|
||||
ebt <- it ^? itUse . heldConsumption . laAmmoType . amBullet . buSpawn
|
||||
return $ colorSH (bulletPayloadColor ebt) $ upperPrismPoly 1.1 $
|
||||
reverse $
|
||||
rectNSWE 0 (- y) (-2) (-1)
|
||||
tails = fromMaybe mempty $ do
|
||||
ebt <- it ^? itUse . heldConsumption . laAmmoType . amBullet . buTrajectory
|
||||
return $ colorSH (bulletTrajColor ebt) $ upperPrismPoly 1.1 $
|
||||
reverse $
|
||||
rectNSWE 0 (- y) 1 2
|
||||
|
||||
makeTinClipAt :: Float -> Point3 -> Item -> Shape
|
||||
makeTinClipAt r p it =
|
||||
translateSH p . overPosSH (rotate3z r) $
|
||||
|
||||
Reference in New Issue
Block a user