Move item inv size and item dimensions from records to external function

This commit is contained in:
2024-11-26 23:36:08 +00:00
parent 9534698a24
commit b21513c4dd
22 changed files with 187 additions and 176 deletions
+4 -5
View File
@@ -7,7 +7,6 @@ import Dodge.Data.Item
makeTypeCraftNum :: Int -> CraftType -> [Item]
makeTypeCraftNum i ct = replicate i $
defaultCraftItem
& itInvSize .~ 1
& itType .~ CRAFT ct
makeTypeCraft :: CraftType -> Item
@@ -28,16 +27,16 @@ makeTypeCraft = head . makeTypeCraftNum 1
--bounceModule = bulletBodyCraft BounceBullet
teleportModule :: Item
teleportModule = makeTypeCraft TELEPORTMODULE & itInvSize .~ 1
teleportModule = makeTypeCraft TELEPORTMODULE
timeModule :: Item
timeModule = makeTypeCraft TIMEMODULE & itInvSize .~ 1
timeModule = makeTypeCraft TIMEMODULE
sizeModule :: Item
sizeModule = makeTypeCraft SIZEMODULE & itInvSize .~ 1
sizeModule = makeTypeCraft SIZEMODULE
gravityModule :: Item
gravityModule = makeTypeCraft GRAVITYMODULE & itInvSize .~ 1
gravityModule = makeTypeCraft GRAVITYMODULE
pipe :: Item
pipe = makeTypeCraft PIPE
+2 -1
View File
@@ -5,6 +5,7 @@ module Dodge.Item.Display (
basicItemDisplay,
) where
import Dodge.Item.InvSize
import Dodge.Data.ComposedItem
import ShortShow
import Data.Maybe
@@ -32,7 +33,7 @@ itemDisplayPad ls rs
basicItemDisplay :: Item -> [String]
basicItemDisplay itm =
Prelude.take (_itInvSize itm) $
Prelude.take (itInvHeight itm) $
itemBaseName itm :
--catMaybes [maybeWarmupStatus itm, maybeRateStatus itm]
catMaybes [maybeWarmupStatus itm]
-6
View File
@@ -22,8 +22,6 @@ teslaGun :: Item
teslaGun =
defaultHeldItem
& itUse . heldParams .~ BeamShooterParams (Just (elecCrackleS,2))
& itDimension . dimRad .~ 9
& itDimension . dimCenter .~ V3 4 0 0
& itParams .~ teslaParams
& itUse . heldDelay .~ NoDelay
& itUse . heldAim . aimWeight .~ 6
@@ -53,8 +51,6 @@ laser =
, _itTgID = Nothing
, _itTgActive = False
}
& itDimension . dimRad .~ 10
& itDimension . dimCenter .~ V3 15 0 0
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandFlat
@@ -74,8 +70,6 @@ tractorGun =
, _itTgID = Nothing
, _itTgActive = False
}
& itDimension . dimRad .~ 10
& itDimension . dimCenter .~ V3 15 0 0
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandUnder
-7
View File
@@ -22,8 +22,6 @@ defaultBangCane =
& itUse . heldParams . rifling .~ ConstFloat 0.9
& itUse . heldParams . recoil .~ 50
& itUse . heldParams . torqueAfter .~ 0.1
& itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0
& itUse . heldDelay . rateMax .~ 6
-- & itUse . heldMods .~ BangCaneMod
& itUse . heldAim . aimStance .~ OneHand
@@ -57,7 +55,6 @@ rifle =
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 25 0
-- & itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
--repeater :: Item
--repeater =
@@ -97,8 +94,4 @@ miniGunX i =
& itUse . heldParams . sidePush .~ 10 * fromIntegral i
& itUse . heldParams . randomOffset .~ 10
& itUse . heldParams . rifling .~ UniRandFloat 0.8 0.9
& itInvSize .~ (i + 3) `div` 2
& itDimension . dimRad .~ 20
& itDimension . dimCenter .~ V3 5 0 0
& itDimension . dimAttachPos .~ V3 5 (-5) 0
& itType .~ HELD (MINIGUNX i)
-4
View File
@@ -11,11 +11,7 @@ import Linear
bangCone :: Item
bangCone =
defaultBulletWeapon
& itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0
& itUse . heldDelay . rateMax .~ 20
-- & itUse . heldMods .~ PistolMod
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles
.~ replicate 15 (Muzzle (V2 15 0) 0 0.5 0 DefaultFlareType MuzzleShootBullet)
& itUse . heldParams . muzVel .~ UniRandFloat 0.5 0.8
-3
View File
@@ -12,9 +12,6 @@ import Geometry.Data
launcher :: Item
launcher =
defaultHeldItem
& itInvSize .~ 3
& itDimension . dimRad .~ 9
& itDimension . dimCenter .~ V3 10 0 0
& itUse . heldDelay . rateMax .~ 20
& itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimRange .~ 0.5
-2
View File
@@ -23,8 +23,6 @@ bangRod =
& itUse . heldParams . torqueAfter .~ 0.3
& itUse . heldParams . bulGunSound ?~ (bangEchoS,0)
& itUse . heldDelay . rateMax .~ 12
& itDimension . dimRad .~ 12
& itDimension . dimCenter .~ V3 5 0 0
& itType .~ HELD BANGROD
& itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimRange .~ 1
-5
View File
@@ -73,12 +73,7 @@ flameThrower :: Item
flameThrower =
defaultHeldItem
& itParams .~ NoParams
& itDimension . dimRad .~ 7
& itDimension . dimCenter .~ V3 9 0 0
-- & itUse . heldUse .~ HeldOverNozzlesUseGasParams -- overNozzles useGasParams
& itUse . heldDelay .~ NoDelay
-- & itUse . heldMods .~ FlameThrowerMod
-- & itUse . heldMods .~ PistolMod
& itUse . heldAim . aimWeight .~ 5
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 5, _izMin = 1.5}
& itUse . heldAim . aimStance .~ TwoHandUnder
-5
View File
@@ -20,12 +20,7 @@ bangStick i =
& itUse . heldParams . recoil .~ 25
& itUse . heldParams . torqueAfter .~ 0.18 + 0.02 * fromIntegral i
& itType .~ HELD (BANGSTICK i)
& itInvSize .~ max 1 (i `div` 2)
& itDimension . dimRad .~ 5
& itDimension . dimCenter .~ V3 5 0 0
& itUse . heldDelay . rateMax .~ 8
-- & itUse . heldMods .~ BangStickMod
-- & itUse . heldMods .~ PistolMod
& itUse . heldAim . aimMuzzles
.~ [Muzzle (V2 10 0) a 0.01 0 DefaultFlareType MuzzleShootBullet | a <- spreadAroundCenter i baseStickSpread]
-1
View File
@@ -14,7 +14,6 @@ flatShield =
& itUse . heldAim . aimTurnSpeed .~ 0.5
& itUse . heldAim . aimStance .~ TwoHandFlat
-- & itUse . heldAim . aimHandlePos .~ 0
& itInvSize .~ 3
& itType .~ HELD FLATSHIELD
keyCard :: Int -> Item
+2 -1
View File
@@ -2,6 +2,7 @@ module Dodge.Item.Info
( itemInfo
) where
import Dodge.Item.InvSize
import Data.Char
--import qualified Data.Map.Strict as M
import Dodge.Data.Item
@@ -15,7 +16,7 @@ itemInfo itm =
++ itmSpaceInfo itm
itmSpaceInfo :: Item -> String
itmSpaceInfo itm = case _itInvSize itm of
itmSpaceInfo itm = case itInvHeight itm of
1 -> " It takes up one inventory slot. "
x -> " It takes up " ++ showInt x ++ " inventory slots. "
+53
View File
@@ -0,0 +1,53 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Item.InvSize (
itInvHeight,
itDim,
) where
import Control.Lens
import Dodge.Data.Item
import Linear.V3
itInvHeight :: Item -> Int
itInvHeight x = case x ^. itType of
HELD (MINIGUNX i) -> (i + 3) `div` 2
HELD LAUNCHER -> 3
HELD FLATSHIELD -> 3
HELD (BANGSTICK i) -> max 1 (i `div` 2)
_ -> 1
itDim :: Item -> ItemDimension
itDim x = case x ^. itType of
HELD TESLAGUN -> ItemDimension 9 (V3 4 0 0) (V3 10 (-5) 3)
HELD LASER -> did & dimRad .~ 10
& dimCenter .~ V3 15 0 0
HELD TRACTORGUN -> did & dimRad .~ 10
& dimCenter .~ V3 15 0 0
HELD FLAMETHROWER -> did & dimRad .~ 7
& dimCenter .~ V3 9 0 0
HELD y | hasCaneGunDim y -> did & dimRad .~ 8
& dimCenter .~ V3 5 0 0
HELD (MINIGUNX {}) -> did & dimRad .~ 20
& dimCenter .~ V3 5 0 0
& dimAttachPos .~ V3 5 (-5) 0
HELD LAUNCHER -> did & dimRad .~ 9
& dimCenter .~ V3 10 0 0
HELD BANGSTICK{} -> did
& dimRad .~ 5
& dimCenter .~ V3 5 0 0
HELD BANGROD -> did
& dimRad .~ 12
& dimCenter .~ V3 5 0 0
HELD BANGCONE -> did
& dimRad .~ 8
& dimCenter .~ V3 5 0 0
_ -> did
hasCaneGunDim :: HeldItemType -> Bool
hasCaneGunDim = \case
VOLLEYGUN {} -> True -- this shouldn't really be the case
RIFLE -> True
_ -> False
did :: ItemDimension
did = ItemDimension 2 0 (V3 10 (-5) 3)