Tweak module display and logic

This commit is contained in:
2023-01-12 12:51:24 +00:00
parent 94c0af97fd
commit 37e26f53e6
19 changed files with 250 additions and 80 deletions
+12 -6
View File
@@ -16,17 +16,23 @@ makeTypeCraftNum i ct =
makeTypeCraft :: CraftType -> Item
makeTypeCraft = makeTypeCraftNum 1
bulletPayloadCraft :: EnergyBallType -> Item
bulletPayloadCraft ebt =
makeTypeCraft (BULPAYLOADMODULE ebt)
& itInvSize .~ 1
& itInvColor .~ chartreuse
incendiaryModule :: Item
incendiaryModule =
makeTypeCraft INCENDIARYMODULE
incendiaryModule = bulletPayloadCraft IncBall
bulletBodyCraft :: BulletEffect -> Item
bulletBodyCraft ebt =
makeTypeCraft (BULBODYMODULE ebt)
& itInvSize .~ 1
& itInvColor .~ chartreuse
bounceModule :: Item
bounceModule =
makeTypeCraft BOUNCEMODULE
& itInvSize .~ 1
& itInvColor .~ chartreuse
bounceModule = bulletBodyCraft BounceBullet
teleportModule :: Item
teleportModule =
+67 -5
View File
@@ -9,10 +9,11 @@ import LensHelp
import Picture
import Shape
import ShapePicture
import qualified Data.Map.Strict as M
itemSPic :: Item -> SPic
itemSPic it =
foldMap (modulesSPic it) (_iyModules $ _itType it) <> case it ^. itType . iyBase of
M.foldMapWithKey (modulesSPic it) (_iyModules $ _itType it) <> case it ^. itType . iyBase of
NoItemType -> over _1 (colorSH magenta) defSPic
CRAFT _ -> defSPic
HELD ht -> heldItemSPic ht it
@@ -55,6 +56,56 @@ 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
--SONICGUN -> noPic baseSonicShape
TRACTORGUN -> Nothing
LAUNCHER -> Nothing
LAUNCHERX _ -> Nothing
REMOTELAUNCHER -> Nothing
POISONSPRAYER -> Nothing
DRONELAUNCHER -> Nothing
SHATTERGUN -> Nothing
HELDDETECTOR _ -> Nothing
KEYCARD _ -> Nothing
BINOCULARS -> Nothing
heldItemSPic :: HeldItemType -> Item -> SPic
heldItemSPic ht it = case ht of
FLATSHIELD -> flatShieldEquipSPic
@@ -131,8 +182,8 @@ torchShape =
bot = upperPrismPoly 0.5 $ rectXH 9 2
back = upperPrismPoly 3 $ rectXH 1 2
modulesSPic :: Item -> ItemModuleType -> SPic
modulesSPic it imt = case imt of
modulesSPic :: Item -> ModuleSlot -> ItemModuleType -> SPic
modulesSPic it _ imt = case imt of
ATTACHTORCH -> noPic (overPosSH (+.+.+ _dimAttachPos (_itDimension it)) torchShape)
_ -> mempty
@@ -189,12 +240,23 @@ makeSingleClipAt p it = case it ^? itUse . heldConsumption . laLoaded of
makeTinClipAt :: Float -> Point3 -> Item -> Shape
makeTinClipAt r p it =
translateSH p . overPosSH (rotate3z r) $
upperPrismPoly 1 $
(upperPrismPoly 1 $
reverse $
rectNSWE 0 (- y) (-2) 2
rectNSWE 0 (- y) (-2) 2) <> tips
where
y = fromIntegral y' * 0.3
y' = fromMaybe 0 $ it ^? itUse . heldConsumption . laLoaded
tips = fromMaybe mempty $ do
ebt <- it ^? itUse . heldConsumption . laAmmoType . amBullet . buSpawn . spawnEBT
return $ colorSH (bulletPayloadColor ebt) $ upperPrismPoly 1.1 $
reverse $
rectNSWE 0 (- y) (-2) (-1)
bulletPayloadColor :: EnergyBallType -> Color
bulletPayloadColor ebt = case ebt of
IncBall -> orange
TeslaBall -> cyan
ConcBall -> white
volleyGunSPic :: Int -> Item -> SPic
volleyGunSPic i it =
+26 -14
View File
@@ -1,5 +1,6 @@
module Dodge.Item.Info where
import Dodge.Module.Info
import Data.Char
import Dodge.Data.Item
import qualified Data.Map.Strict as M
@@ -8,11 +9,12 @@ import LensHelp
itemInfo :: Item -> String
itemInfo itm = itmBaseInfo itm ++ " " ++ itmUsageInfo itm
++ itmSpaceInfo itm
++ itmModuleInfo (itm ^. itType . iyModules)
itmSpaceInfo :: Item -> String
itmSpaceInfo itm = case (ceiling $ _itInvSize itm) of
1 -> "It takes up one inventory slot. "
x -> "It takes up " ++ showInt x ++ " inventory slots. "
1 -> " It takes up one inventory slot. "
x -> " It takes up " ++ showInt x ++ " inventory slots. "
itmBaseInfo :: Item -> String
itmBaseInfo itm = case itm ^. itType . iyBase of
@@ -180,13 +182,10 @@ craftInfo fit = case fit of
BATTERY -> "A store of electical potential energy."
FUELCELL -> "A devices that converts chemical energy into electricity."
PORTABLEFUSION -> "A miniature nuclear reactor."
INCENDIARYMODULE -> "A device that converts projectiles into incendiary projectiles."
STATICMODULE -> "A device that converts projectiles into electrostatic projectiles."
CONCUSSMODULE -> "A device that converts projectiles into concussive projectiles."
BULPAYLOADMODULE ebt -> "A device that converts projectiles into " ++ displayBulletPayload ebt ++ " projectiles."
FRAGMODULE -> "A device that converts projectiles into fragmentation projectiles."
FLASHMODULE -> "A device that converts projectiles into flashbang projectiles."
BOUNCEMODULE -> "A device that converts projectiles into bouncing projectiles."
PENMODULE -> "A device that converts projectiles into pentrating projectiles."
BULBODYMODULE be -> "A device that converts projectiles into " ++ displayBulletBody be ++ " projectiles."
TELEPORTMODULE -> "A device that allows for near-instant translocation across space."
TIMEMODULE -> "A device that can affect temporality."
SIZEMODULE -> "A device that can affect physical size."
@@ -231,23 +230,36 @@ equipSiteInfo es = case es of
GoesOnBack -> " on the back"
GoesOnWrist -> " on a wrist"
GoesOnLegs -> " on both legs"
GoesOnSpecial -> " in a unique location"
itmModuleInfo :: M.Map ModuleSlot ItemModuleType -> String
itmModuleInfo m
| m == mempty = ""
| otherwise = "Modifications can be made "
| otherwise = mms ++ ems
where
(mademods,emptymods) = M.partition (/= EMPTYMODULE) m
mms | mademods == mempty = ""
| otherwise = " Modifications have been made "
++ makeCommaList (map moduleInfo $ M.keys mademods)
ems | emptymods == mempty = ""
| otherwise = " Modifications can be made "
++ makeCommaList (map moduleInfo $ M.keys emptymods)
makeCommaList :: [String] -> String
makeCommaList [] = ""
makeCommaList (x:[]) = x ++ "."
makeCommaList (x:y:[]) = x ++ " and " ++ y ++ "."
makeCommaList (x:xs) = x ++ ", " ++ makeCommaList xs
moduleInfo :: ModuleSlot -> String
moduleInfo imt = case imt of
ModBulletCollision -> "that affect how fired bullets collide with objects"
ModBulletPayload -> "that change bullet payloads"
ModBulletCollision -> "to affect how fired bullets collide with objects"
ModBulletPayload -> "to bullet payloads"
ModRifleMag -> "to the magazine"
ModAutoMag -> "to the magazine"
ModTarget -> "to add a targeting system"
ModBulletTrajectory -> "to the trajectory of fired bullets"
ModTarget -> "to add a targeting system or scope"
ModBulletTrajectory -> "to utilize any installed targeting system to affect the trajectory of fired bullets"
ModLauncherHoming -> "to add a homing system"
ModBattery -> "to its battery system"
ModTeleport -> "to add a teleporation system"
ModDualBeam -> "to the dual beams"
ModHeldAttach -> "by adding an attachment"
ModHeldAttach -> "to add an attachment that may have any number of effects"
+88
View File
@@ -0,0 +1,88 @@
module Dodge.Item.Module where
import Dodge.Data.Item.Combine
import Geometry.Data
moduleAttachPosition :: ItemBaseType -> ModuleSlot -> (Point3, Point3)
moduleAttachPosition ibt ms = case ms of
ModBulletCollision -> (V3 (x - 2.5) y (0.5 * z) , V3 0 1 0)
ModBulletPayload -> (V3 (-x) 0 (0.5 * z), V3 (-1) 0 0)
ModRifleMag -> undefined
ModAutoMag -> undefined
ModTarget -> (V3 0 0 z, V3 0 0 1)
ModBulletTrajectory -> undefined
ModLauncherHoming -> undefined
ModBattery -> undefined
ModTeleport -> undefined
ModDualBeam -> undefined
ModHeldAttach -> undefined
where
V3 x y z = itBounds ibt
itBounds :: ItemBaseType -> Point3
itBounds ibt = case ibt of
HELD hit -> heldBounds hit
_ -> V3 0 0 0
heldBounds :: HeldItemType -> Point3
heldBounds hit = case hit of
BANGSTICK _ -> V3 0 0 0
PISTOL -> bss
REVOLVER -> bss
REVOLVERX _ -> bss
MACHINEPISTOL -> bss
AUTOPISTOL -> bss
SMG -> smgs
BANGCONE -> cs
BLUNDERBUSS -> bbs
GRAPECANNON _ -> bbs
MINIGUNX _ -> minis
VOLLEYGUN _ -> undefined
RIFLE -> rs
REPEATER -> rs
AUTORIFLE -> rs
BURSTRIFLE -> rs
BANGROD -> amrs
ELEPHANTGUN -> amrs
AMR -> amrs
AUTOAMR -> amrs
SNIPERRIFLE -> amrs
MACHINEGUN -> amrs
FLAMESPITTER -> fs
FLAMETHROWER -> fs
FLAMETORRENT -> fs
FLAMEWALL -> fs
BLOWTORCH -> fs
SPARKGUN -> ts
TESLAGUN -> ts
LASGUN -> ls
LASCIRCLE -> ls
DUALBEAM -> ls
LASWIDE _ -> ls
TRACTORGUN -> ls
LAUNCHER -> launchs
LAUNCHERX _ -> launchs
REMOTELAUNCHER -> launchs
POISONSPRAYER -> fs
DRONELAUNCHER -> fs
SHATTERGUN -> launchs
FORCEFIELDGUN -> launchs
HELDDETECTOR _ -> launchs
TORCH -> launchs
BINOCULARS -> launchs
FLATSHIELD -> launchs
KEYCARD _ -> launchs
where
bss = V3 10 2 3
smgs = V3 20 2 3
cs = V3 5 2 3
bbs = V3 20 2 3
minis = V3 10 2 3
rs = V3 25 2 3
amrs = V3 30 2 3
fs = V3 10 2 3
ts = V3 10 2 3
ls = V3 30 2 3
launchs = V3 10 10 10