Implement filter on nearby objects

This commit is contained in:
2023-02-17 11:19:07 +00:00
parent 93dfc2a67c
commit c0ef36426a
8 changed files with 103 additions and 18 deletions
+6 -5
View File
@@ -175,7 +175,7 @@ updateCloseObjects w =
where
newcloseobjects = unionBy closeObjEq oldCloseFiltered currentClose
updatecursorposifnecessary
= case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject. ispCloseObject of
= case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject. inNearby . ispCloseObject of
Just i | i >= length newcloseobjects -> changeAugInvSel 1
_ -> id
filt = filter $ \obj -> dist ypos (closeObjPos obj) < 40 && hasButtonLOS ypos (closeObjPos obj) w
@@ -328,8 +328,8 @@ closeObjScrollDir x
changeSwapInvSel :: Int -> World -> World
changeSwapInvSel k w = case you w ^? crManipulation . manObject of
Just (InInventory (SelItem i _)) -> w & cWorld . lWorld . creatures . ix 0 %~ updatecreature i
Just (SelCloseObject i) -> w
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseObject
Just (InNearby (SelCloseObject i)) -> w
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . inNearby . ispCloseObject
.~ ((i - k) `mod` numCO)
& hud . closeObjects %~ swapIndices i ((i - k) `mod` numCO)
_ -> w
@@ -372,7 +372,8 @@ setInvPosFromSS w = w
(-1) -> Just $ InInventory SortInventory
0 -> Just $ InInventory (SelItem j NoInvSelAction)
1 -> Just SelNothing
2 -> Just $ SelCloseObject j
2 -> Just $ InNearby SortNearby
3 -> Just $ InNearby $ SelCloseObject j
_ -> error "selection out of bounds"
-- this should be in a separate module
@@ -497,7 +498,7 @@ bestCloseObjectIndex w = findIndex f $ w ^. hud . closeObjects
ycr = you w
selectedCloseObject :: World -> Maybe (Int, Either FloorItem Button)
selectedCloseObject w = case you w ^? crManipulation . manObject . ispCloseObject of
selectedCloseObject w = case you w ^? crManipulation . manObject . inNearby . ispCloseObject of
Just i -> selectNthCloseObject w i
Nothing -> selectNthCloseObject w =<< bestCloseObjectIndex w