Auto create tree structure for held item ammo, add derive instances

This commit is contained in:
2024-09-13 17:34:29 +01:00
parent fb104a1719
commit 338d9e8422
10 changed files with 72 additions and 49 deletions
+1
View File
@@ -39,6 +39,7 @@ beltMag =
tinMag & itType . iyBase . ibtAmmoMag .~ BELTMAG
& itUse . amagLoadStatus . iaLoaded .~ 10000
& itUse . amagLoadStatus . iaMax .~ 20000
& itUse . amagType .~ BeltBulletAmmo
shellMag :: Item
shellMag =
+17 -7
View File
@@ -28,16 +28,26 @@ singleDT x = DT x [] []
singleLDT :: a -> LabelDoubleTree b a
singleLDT x = LDT x [] []
baseComposedItem' :: ItemBaseType -> CIL
baseComposedItem' ibt = case ibt of
HELD BURSTRIFLE -> (WeaponCI, [(AmmoInLink,BulletAmmoCI)], [])
AMMOMAG TINMAG -> (BulletAmmoCI, [(AmmoModLink,AmmoModifierCI)], [])
AMMOMAG DRUMMAG -> (BulletAmmoCI, [(AmmoModLink,AmmoModifierCI)], [])
ATTACH BULLETSYNTHESIZER -> (AmmoModifierCI, [], [])
baseComposedItem :: ItemBaseType -> Item -> CIL
baseComposedItem ibt itm = case ibt of
HELD _ -> heldComposedItem itm
AMMOMAG _ -> ammoComposedItem itm
ATTACH BULLETSYNTHESIZER -> (AmmoModifierCI BulletAmmo, [], [])
_ -> (UncomposableCI, [], [])
heldComposedItem :: Item -> CIL
heldComposedItem itm = (WeaponCI, map f ats, [])
where
ats = itm ^.. itUse . heldAmmoTypes . traverse
f atype = (AmmoInLink atype,AmmoCI atype)
ammoComposedItem :: Item -> CIL
ammoComposedItem itm = fromMaybe (error "in ammoComposedItem, wrong item") $ do
atype <- itm ^? itUse . amagType
return (AmmoCI atype, [(AmmoModLink,AmmoModifierCI atype)], [])
baseCIS :: Item -> ComposedItemStructure
baseCIS itm = let (a,b,c) = baseComposedItem' (itm ^. itType . iyBase)
baseCIS itm = let (a,b,c) = baseComposedItem (itm ^. itType . iyBase) itm
in (itm, a, b, c)
type LDTTest a b = LabelDoubleTree b a -> LabelDoubleTree b a -> Maybe b
+1 -1
View File
@@ -101,7 +101,7 @@ miniGunUse i =
& heldAim . aimRange .~ 1
& heldAim . aimStance .~ TwoHandUnder
& heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& heldAmmoTypes .~ [BulletAmmo]
& heldAmmoTypes .~ [BeltBulletAmmo]
miniGunX :: Int -> Item
miniGunX i =