Simplify item composition structure

This commit is contained in:
2025-06-26 21:07:11 +01:00
parent 758c0aeec8
commit 377900662a
9 changed files with 195 additions and 208 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ itemTreeSPic (LDT (itm,_,_) l r) =
itemRotTreeSPic :: Item -> (ItemLink, LabelDoubleTree ItemLink CItem) -> SPic
itemRotTreeSPic par (il, t) = translateSP p . overPosSP (Q.rotate q) $ itemTreeSPic t
where
(p, q) = orientAttachment par (_iatType il) itm
(p, q) = orientAttachment par il itm
itm = t ^. ldtValue . _1
itemSPic :: Item -> SPic
+10 -10
View File
@@ -34,12 +34,12 @@ tryAttachItems ::
tryAttachItems = leftRightCombine leftIsParentCombine rightIsParentCombine
useBreakL ::
[(ItemStructuralFunction, CLinkType)] ->
[(ItemStructuralFunction, CLinkType)] ->
[(ItemStructuralFunction, ItemLink)] ->
[(ItemStructuralFunction, ItemLink)] ->
LinkTest
useBreakL x y = useBreakListsLinkTest (map (uncurry noa) x) (map (uncurry noa) y)
where
noa a b = (a, ILink b)
noa a b = (a, b)
useBreakListsLinkTest ::
[(ItemStructuralFunction, ItemLink)] ->
@@ -67,7 +67,7 @@ useBreakListsLinkTest llist rlist = LTest ltest rtest
itemToBreakLists ::
Item ->
ItemStructuralFunction ->
([(ItemStructuralFunction, CLinkType)], [(ItemStructuralFunction, CLinkType)])
([(ItemStructuralFunction, ItemLink)], [(ItemStructuralFunction, ItemLink)])
itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
(HELD TORCH, _) -> (getAmmoLinks itm, [])
(ATTACH UNDERBARRELSLOT, _) -> ([(UnderBarrelPlatformSF, UnderBarrelPlatformLink)], [])
@@ -117,12 +117,12 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
([(AmmoMagSF ElectricalAmmo, AmmoInLink 0 ElectricalAmmo)], [])
_ -> ([], [])
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, ItemLink)]
getAutoSpringLinks itm = case itemTriggerType itm of
HammerTrigger -> [(MakeAutoSF, MakeAutoLink)]
_ -> []
extraWeaponLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
extraWeaponLinks :: Item -> [(ItemStructuralFunction, ItemLink)]
extraWeaponLinks itm = case itm ^. itType of
HELD GLAUNCHER -> launcherlinks <> [(GrenadeHitEffectSF,GrenadeHitEffectLink)]
HELD RLAUNCHER -> launcherlinks
@@ -131,14 +131,14 @@ extraWeaponLinks itm = case itm ^. itType of
where
launcherlinks = [(ProjectileStabiliserSF,ProjectileStabiliserLink)]
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction, CLinkType)]
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction, ItemLink)]
extraWeaponLinksBelow itm
-- | Just TwoHandUnder <- itm ^? itUse . heldAim . aimStance
| TwoHandUnder <- itemBaseStance itm
= [(UnderBarrelSlotSF,UnderBarrelSlotLink)]
| otherwise = []
getAmmoLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
getAmmoLinks :: Item -> [(ItemStructuralFunction, ItemLink)]
getAmmoLinks itm =
map
(\(i, a) -> (AmmoMagSF a, AmmoInLink i a))
@@ -215,7 +215,7 @@ llright itm pci = case pci ^. ldtValue . _1 . itType of
toLasgunUpdate :: Item -> LinkUpdate
toLasgunUpdate itm =
LUpdate
(ILink FunctionChangeLink)
FunctionChangeLink
(\(par, _, _) -> (par, HeldPlatformSF, uncurry useBreakL $ itemToBreakLists itm HeldPlatformSF))
(\(chi, _, up) -> (chi, FunctionChangeSF, up))
@@ -225,7 +225,7 @@ springLinkTest = LTest (const Nothing) $
CRAFT HARDWARE ->
Just
( LUpdate
(ILink FunctionChangeLink)
(FunctionChangeLink)
(\(par, _, up) -> (par, MakeAutoSF, up))
(\(chi, _, up) -> (chi, FunctionChangeSF, up))
)
+2 -2
View File
@@ -13,14 +13,14 @@ orientChild itm = case _itType itm of
HELD LASER -> (V3 15 (-5) 0, Q.qID)
_ -> (0, Q.qID)
orientByLink :: Item -> CLinkType -> (Point3, Q.Quaternion Float)
orientByLink :: Item -> ItemLink -> (Point3, Q.Quaternion Float)
orientByLink itm lt = case (_itType itm, lt) of
(HELD FLAMETHROWER, AmmoInLink{}) -> (V3 4 (-6) 0, Q.qID)
(HELD _, AmmoInLink{}) -> (V3 7 (-2) 0, Q.qID)
(HELD _, WeaponScopeLink) -> (V3 5 0 5, Q.qID)
_ -> (0, Q.qID)
orientAttachment :: Item -> CLinkType -> Item -> (Point3, Q.Quaternion Float)
orientAttachment :: Item -> ItemLink -> Item -> (Point3, Q.Quaternion Float)
orientAttachment par lnk ch = case (_itType par, lnk, _itType ch) of
-- (HELD BURSTRIFLE, _, HELD TORCH) -> (V3 20 0 0, Q.axisAngle (V3 0 0 1) (pi/2))
-- (HELD LAUNCHER, _, HELD TORCH) -> (V3 0 20 0, Q.axisAngle (V3 0 0 1) (pi/4))