Cleanup, split itemToBreakLists

This commit is contained in:
2025-07-13 22:24:54 +01:00
parent d861be8acf
commit 27ce087e33
2 changed files with 81 additions and 65 deletions
+1 -27
View File
@@ -141,12 +141,6 @@ craftItemSPic = \case
. upperCylinder Small Typical 1 . upperCylinder Small Typical 1
$ polyCirc 3 4 $ polyCirc 3 4
-- FRAGMODULE
-- FLASHMODULE
-- GASINJECTOR
-- FLAKCRAFT
-- FRAGCRAFT
ammoMagSPic :: Item -> AmmoMagType -> SPic ammoMagSPic :: Item -> AmmoMagType -> SPic
ammoMagSPic it = \case ammoMagSPic it = \case
TINMAG -> noPic $ upperPrismPolyTS 1 (rectNSWE 0 (- (am * 5)) (-1) 1) TINMAG -> noPic $ upperPrismPolyTS 1 (rectNSWE 0 (- (am * 5)) (-1) 1)
@@ -385,10 +379,7 @@ volleyGunShape i =
-- to get this rotating should probably add extra state to the minigun -- to get this rotating should probably add extra state to the minigun
miniGunXPictItem :: Int -> Item -> SPic miniGunXPictItem :: Int -> Item -> SPic
miniGunXPictItem i it = miniGunXPict i spin miniGunXPictItem i it = miniGunXPict i (_wTime (_itParams it) - 10)
where
--spin = (-10) + _warmTime (_heldDelay $ _itUse it)
spin = (-10) + _wTime (_itParams it)
miniGunXPict :: Int -> Int -> SPic miniGunXPict :: Int -> Int -> SPic
miniGunXPict i spin = miniGunXPict i spin =
@@ -421,14 +412,6 @@ rlauncherPic _ = noPic . colorSH cyan $ xCylinderST 5 20
glauncherPic :: Item -> SPic glauncherPic :: Item -> SPic
glauncherPic _ = noPic . colorSH green $ xCylinderST 5 20 glauncherPic _ = noPic . colorSH green $ xCylinderST 5 20
--launcherPic _ = noPic . colorSH cyan $ xCylinder 4 5 20
-- ( colorSH cyan $
-- prismPoly
-- (map (+.+.+ V3 20 0 5) $ polyCircx 4 5)
-- (map (+.+.+ V3 0 0 5) $ polyCircx 4 5)
-- , mempty
-- )
baseRodShape :: Shape baseRodShape :: Shape
baseRodShape = colorSH orange $ xCylinderST 3 20 baseRodShape = colorSH orange $ xCylinderST 3 20
@@ -494,14 +477,5 @@ keyPic =
, thickLine 2 $ map toV2 [(4, 0), (4, -4)] , thickLine 2 $ map toV2 [(4, 0), (4, -4)]
] ]
--latchkeyPic :: Picture
--latchkeyPic =
-- color yellow $
-- pictures
-- [ translate (-4) 0 $ thickCircle 4 2
-- , thickLine 2 $ map toV2 [(0, 0), (8, 0), (8, -4)]
-- , thickLine 2 $ map toV2 [(4, 0), (4, -4)]
-- ]
legsSPic :: Color -> SPic legsSPic :: Color -> SPic
legsSPic col = noPic $ translateSH (V3 0 4 0) $ colorSH col $ upperPrismPolyST 3 $ rectWH 2 2 legsSPic col = noPic $ translateSH (V3 0 4 0) $ colorSH col $ upperPrismPolyST 3 $ rectWH 2 2
+80 -38
View File
@@ -33,33 +33,27 @@ import ListHelp
tryAttachItems :: DTree CItem -> DTree CItem -> Maybe (DTree CItem) tryAttachItems :: DTree CItem -> DTree CItem -> Maybe (DTree CItem)
tryAttachItems = leftRightCombine leftIsParentCombine rightIsParentCombine tryAttachItems = leftRightCombine leftIsParentCombine rightIsParentCombine
itemToBreakLists :: Item -> ItemSF -> ([ItemSF], [ItemSF]) itemAboveAttachables :: CItem -> [ItemSF]
itemToBreakLists itm itmf = case (itm ^. itType, itmf) of itemAboveAttachables (itm,sf) = case (itm ^. itType, sf) of
(HELD TORCH, _) -> (getAmmoLinks itm, [])
(ATTACH UNDERBARRELSLOT, _) -> ([UnderBarrelPlatformSF], [])
(_, HeldPlatformSF) -> (_, HeldPlatformSF) ->
( getAmmoLinks itm [WeaponTargetingSF, WeaponScopeSF]
<> extraWeaponLinksBelow itm
, [WeaponTargetingSF, WeaponScopeSF]
<> getAutoSpringLinks itm <> getAutoSpringLinks itm
<> extraWeaponLinks itm <> extraWeaponLinks itm
) (DETECTOR {}, _) -> [ARHUDSF,TriggerSF,MapperSF]
(_, UnderBarrelPlatformSF) -> (CRAFT TRANSFORMER, _) -> [LaserWeaponSF]
( getAmmoLinks itm,[]) (MAPPER, _) -> [ARHUDSF]
(DETECTOR {}, _) -> (_, GadgetPlatformSF) -> [TriggerSF, WeaponTargetingSF, WeaponScopeSF]
( getAmmoLinks itm _ -> []
, [ARHUDSF,TriggerSF,MapperSF]
) itemBelowAttachables :: CItem -> [ItemSF]
(CRAFT TRANSFORMER, _) -> ([],[LaserWeaponSF]) itemBelowAttachables (itm,sf) = case (itm ^. itType, sf) of
(MAPPER, _) -> (HELD TORCH, _) -> getAmmoLinks itm
( [] (ATTACH UNDERBARRELSLOT, _) -> [UnderBarrelPlatformSF]
, [ARHUDSF] (_, HeldPlatformSF) -> getAmmoLinks itm <> extraWeaponLinksBelow itm
) (_, UnderBarrelPlatformSF) -> getAmmoLinks itm
(_, GadgetPlatformSF) -> (DETECTOR {}, _) -> getAmmoLinks itm
( getAmmoLinks itm (_, GadgetPlatformSF) -> getAmmoLinks itm
, [TriggerSF, WeaponTargetingSF, WeaponScopeSF] (_, AmmoMagSF{}) -> fromMaybe [] $ do
)
(_, AmmoMagSF{}) -> fromMaybe ([], []) $ do
atype <- magAmmoType itm atype <- magAmmoType itm
let screenanddet = case atype of let screenanddet = case atype of
LauncherAmmo -> LauncherAmmo ->
@@ -67,24 +61,72 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
, RemoteDetonatorSF , RemoteDetonatorSF
] ]
_ -> [] _ -> []
return return $
( [ AmmoModifierSF atype [ AmmoModifierSF atype
, AmmoTargetingSF atype , AmmoTargetingSF atype
, AmmoPayloadSF atype , AmmoPayloadSF atype
, AmmoEffectSF atype , AmmoEffectSF atype
, SmokeReducerSF , SmokeReducerSF
] ]
<> screenanddet <> screenanddet
, []
) (_, RemoteScreenSF) -> [JoystickSF]
(_, RemoteScreenSF) -> (_, WeaponTargetingSF) -> getAmmoLinks itm ++ [ARHUDSF]
( [JoystickSF] (ATTACH BULLETSYNTH, _) -> [AmmoMagSF 0 ElectricalAmmo]
, [] _ -> []
)
(_, WeaponTargetingSF) -> (getAmmoLinks itm ++ [ARHUDSF], []) --itemToBreakLists :: Item -> ItemSF -> ([ItemSF], [ItemSF])
(ATTACH BULLETSYNTH, _) -> --itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
([AmmoMagSF 0 ElectricalAmmo], []) -- (HELD TORCH, _) -> (getAmmoLinks itm, [])
_ -> ([], []) -- (ATTACH UNDERBARRELSLOT, _) -> ([UnderBarrelPlatformSF], [])
-- (_, HeldPlatformSF) ->
-- ( getAmmoLinks itm
-- <> extraWeaponLinksBelow itm
-- , [WeaponTargetingSF, WeaponScopeSF]
-- <> getAutoSpringLinks itm
-- <> extraWeaponLinks itm
-- )
-- (_, UnderBarrelPlatformSF) ->
-- ( getAmmoLinks itm,[])
-- (DETECTOR {}, _) ->
-- ( getAmmoLinks itm
-- , [ARHUDSF,TriggerSF,MapperSF]
-- )
-- (CRAFT TRANSFORMER, _) -> ([],[LaserWeaponSF])
-- (MAPPER, _) ->
-- ( []
-- , [ARHUDSF]
-- )
-- (_, GadgetPlatformSF) ->
-- ( getAmmoLinks itm
-- , [TriggerSF, WeaponTargetingSF, WeaponScopeSF]
-- )
-- (_, AmmoMagSF{}) -> fromMaybe ([], []) $ do
-- atype <- magAmmoType itm
-- let screenanddet = case atype of
-- LauncherAmmo ->
-- [ RemoteScreenSF
-- , RemoteDetonatorSF
-- ]
-- _ -> []
-- return
-- ( [ AmmoModifierSF atype
-- , AmmoTargetingSF atype
-- , AmmoPayloadSF atype
-- , AmmoEffectSF atype
-- , SmokeReducerSF
-- ]
-- <> screenanddet
-- , []
-- )
-- (_, RemoteScreenSF) ->
-- ( [JoystickSF]
-- , []
-- )
-- (_, WeaponTargetingSF) -> (getAmmoLinks itm ++ [ARHUDSF], [])
-- (ATTACH BULLETSYNTH, _) ->
-- ([AmmoMagSF 0 ElectricalAmmo], [])
-- _ -> ([], [])
getAutoSpringLinks :: Item -> [ItemSF] getAutoSpringLinks :: Item -> [ItemSF]
getAutoSpringLinks itm = case baseItemTriggerType itm of getAutoSpringLinks itm = case baseItemTriggerType itm of
@@ -171,13 +213,13 @@ rightIsParentCombine ltree rtree = do
leftChildList :: DTree CItem -> [ItemSF] leftChildList :: DTree CItem -> [ItemSF]
leftChildList t = foldl' f l (reverse $ t ^.. dtLeft . each . dtValue . _2) leftChildList t = foldl' f l (reverse $ t ^.. dtLeft . each . dtValue . _2)
where where
l = fst $ itemToBreakLists (t ^. dtValue . _1) (t ^. dtValue . _2) l = itemBelowAttachables (t ^. dtValue)
f x y = tail $ dropWhile (/=y) x f x y = tail $ dropWhile (/=y) x
rightChildList :: DTree CItem -> [ItemSF] rightChildList :: DTree CItem -> [ItemSF]
rightChildList t = foldl' f l (reverse $ t ^.. dtRight . each . dtValue . _2) rightChildList t = foldl' f l (reverse $ t ^.. dtRight . each . dtValue . _2)
where where
l = snd $ itemToBreakLists (t ^. dtValue . _1) (t ^. dtValue . _2) l = itemAboveAttachables (t ^. dtValue)
f x y = tail $ dropWhile (/=y) x f x y = tail $ dropWhile (/=y) x
leftRightCombine :: DTComb a -> DTComb a -> DTree a -> DTree a -> Maybe (DTree a) leftRightCombine :: DTComb a -> DTComb a -> DTree a -> DTree a -> Maybe (DTree a)