Refactor floor items to use centralised items intmap
This commit is contained in:
@@ -134,23 +134,23 @@ tryPickupSelected k mpos w = do
|
||||
let nfreeslots = crNumFreeSlots cr
|
||||
xs <- w ^? hud . hudElement . diSelection . _Just . _3
|
||||
let itmstopickup = mapMaybe g $ IS.toList xs
|
||||
let slotsneeded = alaf Sum foldMap (itInvHeight . _flIt) itmstopickup
|
||||
let slotsneeded = alaf Sum foldMap itInvHeight itmstopickup
|
||||
guard $ nfreeslots >= slotsneeded
|
||||
return $ case mpos of
|
||||
Just (0, j) ->
|
||||
foldr (pickUpItemAt j 0) w itmstopickup
|
||||
foldr (pickUpItemAt j 0) w (IS.toList xs)
|
||||
& hud . hudElement . diSelection
|
||||
?~ ( 0
|
||||
, j
|
||||
, IS.fromDistinctAscList [j .. j + IS.size xs -1]
|
||||
)
|
||||
_ ->
|
||||
foldl' (flip $ pickUpItem 0) w itmstopickup
|
||||
foldl' (flip $ pickUpItem 0) w (IS.toList xs)
|
||||
& hud . hudElement . diSelection . _Just . _3 %~ const mempty
|
||||
where
|
||||
g i = do
|
||||
NInt j <- w ^? hud . closeItems . ix i
|
||||
w ^? cWorld . lWorld . floorItems . ix j
|
||||
w ^? cWorld . lWorld . items . ix j
|
||||
|
||||
updateMouseReleaseInGame :: World -> World
|
||||
updateMouseReleaseInGame w = case w ^. input . mouseContext of
|
||||
@@ -524,14 +524,13 @@ spaceAction w = case w ^. hud . hudElement of
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
_ -> w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
|
||||
getCloseObj :: World -> Maybe (Either FloorItem Button)
|
||||
getCloseObj :: World -> Maybe (Either (NewInt ItmInt) Button)
|
||||
getCloseObj w = getSelectedCloseObj w <|> topcitem <|> topcbut
|
||||
where
|
||||
topcitem = do
|
||||
k' <- (w ^? hud . hudElement . diSections . ix 3 . ssItems)
|
||||
>>= (fmap fst . IM.lookupMin)
|
||||
NInt k <- w ^? hud . closeItems . ix k'
|
||||
Left <$> w ^? cWorld . lWorld . floorItems . ix k
|
||||
Left <$> w ^? hud . closeItems . ix k'
|
||||
topcbut = do
|
||||
k <- w ^? hud . closeButtons . ix 0
|
||||
Right <$> w ^? cWorld . lWorld . buttons . ix k
|
||||
|
||||
Reference in New Issue
Block a user