Flatten values in creature manipulation data types

This commit is contained in:
2024-09-24 21:50:21 +01:00
parent fe00af0e73
commit 25cec10313
24 changed files with 69 additions and 86 deletions
+6 -6
View File
@@ -88,26 +88,26 @@ moveZoomCamera cfig theinput cr campos =
where
vfoffset = fromMaybe 0 $ do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
i <- cr ^? crManipulation . manObject . imSelectedItem
(cr ^? crInv . ix i . itScope . remotePos)
docamrot = rotateV (campos ^. camRot)
offset = fromMaybe noscopeoffset $ do
guard (SDL.ButtonRight `M.member` _mouseButtons theinput)
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
i <- cr ^? crManipulation . manObject . imSelectedItem
(fmap docamrot (cr ^? crInv . ix i . itScope . opticPos))
<|> (cr ^? crInv . ix i . itScope . remotePos)
noscopeoffset = docamrot $
((newzoom - newDefaultZoom) / (newDefaultZoom * newzoom)) *.* _mousePos theinput
newzoom = fromMaybe (newDefaultZoom * newItemZoom) $ do
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
i <- cr ^? crManipulation . manObject . imSelectedItem
(cr ^? crInv . ix i . itScope . opticZoom)
idealDefaultZoom = clipZoom wallZoom
newDefaultZoom = fromMaybe (changeZoom (campos ^. camDefaultZoom) idealDefaultZoom) $ do
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
i <- cr ^? crManipulation . manObject . imSelectedItem
(cr ^? crInv . ix i . itScope . opticZoom)
idealItemZoom = fromMaybe 1 $ do
guard $ crIsAiming cr
i <- cr ^? crManipulation . manObject . inInventory . imSelectedItem
i <- cr ^? crManipulation . manObject . imSelectedItem
zoomFromItem <$> (cr ^? crInv . ix i . itUse . heldAim . aimZoom)
newItemZoom = changeZoom (campos ^. camItemZoom) idealItemZoom
changeZoom curZoom idealZoom
@@ -128,7 +128,7 @@ moveZoomCamera cfig theinput cr campos =
-- is wanted
updateScopeZoom :: World -> World
updateScopeZoom w = fromMaybe w $ do
i <- you w ^? crManipulation . manObject . inInventory . imSelectedItem
i <- you w ^? crManipulation . manObject . imSelectedItem
return $ updateScopeZoom' i w
updateScopeZoom' :: Int -> World -> World
+2 -2
View File
@@ -46,7 +46,7 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
_ -> w
where
rbscrollmax = fromMaybe 1 $ do
invid <- you w ^? crManipulation . manObject . inInventory . imSelectedItem
invid <- you w ^? crManipulation . manObject . imSelectedItem
esite <- you w ^? crInv . ix invid . itUse . equipEffect . eeSite
return $ length $ equipSiteToPositions esite
y = fromIntegral yi
@@ -117,7 +117,7 @@ moveTweakSel i w = case yourSelectedItem w ^? _Just . itTweaks . tweakParams of
changeTweakParam :: Maybe Int -> Int -> World -> World
changeTweakParam mi i w = fromMaybe w $ do
curpos <- you w ^? crManipulation . manObject . inInventory . imSelectedItem
curpos <- you w ^? crManipulation . manObject . imSelectedItem
paramid <- mi
params <- yourSelectedItem w ^? _Just . itTweaks . tweakParams . ix paramid
let x = (_tweakVal params + i) `mod` _tweakMax params