Fix inventory bug
This commit is contained in:
+12
-15
@@ -25,19 +25,19 @@ module Dodge.Inventory (
|
||||
invDimColor,
|
||||
) where
|
||||
|
||||
import Dodge.Reloading
|
||||
import Color
|
||||
import Dodge.Inventory.Color
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
import Dodge.Base
|
||||
import Dodge.Data.World
|
||||
import Dodge.Data.Config
|
||||
import Dodge.Data.World
|
||||
import Dodge.Euse
|
||||
import Dodge.Inventory.CheckSlots
|
||||
import Dodge.Inventory.CloseObject
|
||||
import Dodge.Inventory.Color
|
||||
import Dodge.Inventory.ItemSpace
|
||||
import Dodge.ItEffect
|
||||
import Dodge.Reloading
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
@@ -104,9 +104,9 @@ augmentedInvSizes = trimapAugmentInv itSlotsTaken 1 closeObjectSize
|
||||
trimapAugmentInv :: (Item -> a) -> a -> (Either FloorItem Button -> a) -> World -> IM.IntMap a
|
||||
trimapAugmentInv f x g w =
|
||||
IM.insert n x $
|
||||
IM.union
|
||||
(f <$> yourInv w)
|
||||
(IM.fromAscList $ zip [n + 1 ..] $ map g $ w ^. hud . closeObjects)
|
||||
IM.union
|
||||
(f <$> yourInv w)
|
||||
(IM.fromAscList $ zip [n + 1 ..] $ map g $ w ^. hud . closeObjects)
|
||||
where
|
||||
n = length $ yourInv w
|
||||
|
||||
@@ -166,8 +166,7 @@ updateCloseObjects w =
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ updateinvsel
|
||||
where
|
||||
updateinvsel curinvsel
|
||||
-- | length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w) - 1
|
||||
| length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w)
|
||||
| length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w) - 1
|
||||
| otherwise = curinvsel
|
||||
filt = filter $ \obj -> dist ypos (closeObjPos obj) < 40 && hasButtonLOS ypos (closeObjPos obj) w
|
||||
ypos = _crPos $ you w
|
||||
@@ -332,7 +331,7 @@ changeSwapInvSel k w
|
||||
| yourInvSel w > n =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos .~ ico'
|
||||
& hud . closeObjects %~ swapIndices (i - (n+1)) (ico' - (n+1))
|
||||
& hud . closeObjects %~ swapIndices (i - (n + 1)) (ico' - (n + 1))
|
||||
| otherwise = w
|
||||
where
|
||||
updatecreature =
|
||||
@@ -357,12 +356,10 @@ changeSwapInvSel k w
|
||||
numCO = length $ w ^. hud . closeObjects
|
||||
|
||||
changeAugInvSel :: Int -> World -> World
|
||||
changeAugInvSel i w
|
||||
| n == 0 = w
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction
|
||||
changeAugInvSel i w =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselPos %~ (`mod` n) . subtract i
|
||||
& cWorld . lWorld . creatures . ix 0 . crInvSel . iselAction .~ NoInvSelAction
|
||||
where
|
||||
n = length (yourInv w) + length (w ^. hud . closeObjects) + 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user