This commit is contained in:
2025-08-26 19:35:19 +01:00
parent 1ebdbdd8ae
commit e5473d1028
4 changed files with 53 additions and 77 deletions
+11 -33
View File
@@ -37,9 +37,7 @@ import NewInt
-- should consider never fully destroying items, but assigning a flag saying how
-- they were moved from play
destroyInvItem :: Int -> NewInt InvInt -> World -> World
destroyInvItem cid invid w =
rmInvItem cid invid w & removeitloc
& removeithotkey
destroyInvItem cid invid w = rmInvItem cid invid w & removeitloc & removeithotkey
where
removeitloc = fromMaybe id $ do
itid <- w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
@@ -97,13 +95,9 @@ rmInvItem cid invid w =
itid = _crInv cr ^?! ix invid
itm = w ^?! cWorld . lWorld . items . ix itid
dounequipfunction = effectOnRemove itm cr
-- fromMaybe id $ do
-- rmf <- itm ^? itUse . uequipEffect . eeOnRemove
-- return $ doItmCrWdWd rmf itm cr
removeAnySlotEquipment = fromMaybe id $ do
epos <-
w
^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
>>= \k -> w ^? cWorld . lWorld . items . ix k
. itLocation
. ilEquipSite
@@ -120,23 +114,22 @@ rmInvItem cid invid w =
updateCloseObjects :: World -> World
updateCloseObjects w =
w & hud . closeItems %~ f
& hud . closeButtons %~ g
w & hud . closeItems %~ h citems
& hud . closeButtons %~ h cbts
where
g oldbts = intersect oldbts cbts `union` cbts
f olditems = intersect olditems citems `union` citems
h a b = intersect b a `union` a
lw = w ^. cWorld . lWorld
citems = let is = IM.filter (isclose . _flItPos) (lw^.floorItems)
in map NInt $ IM.keys $ IM.intersection (lw ^. items) is
isclose x = dist y x < 40 && hasButtonLOS y x w
y = _crPos $ you w
citems = map NInt $ IM.keys $ IM.intersection (lw ^. items)
$ IM.filter (isclose . _flItPos) (lw^.floorItems)
cbts = lw^..buttons . each . filtered canpress . filtered (isclose . _btPos) . to _btID
canpress bt = case bt ^. btEvent of
ButtonPress{_btOn = t} -> not t
ButtonAccessTerminal tid -> fromMaybe False $ do
x <- w ^? cWorld . lWorld . terminals . ix tid . tmStatus
x <- lw ^? terminals . ix tid . tmStatus
return (x /= TerminalDeactivated)
_ -> True
isclose x = dist y x < 40 && hasButtonLOS y x w
y = _crPos $ you w
changeSwapSel :: Int -> World -> World
changeSwapSel yi w
@@ -184,13 +177,6 @@ changeSwapWith f w
| Just (Sel j i _) <- w ^. hud . diSelection = swapItemWith f (j,i) w
| otherwise = w
--changeSwapWith :: (Int -> IM.IntMap (SelectionItem ()) -> Maybe Int) -> World -> World
--changeSwapWith f w = case w ^? hud . hudElement . diSelection . _Just of
-- Just (0, i, _) -> w & swapInvItems f i
-- Just (3, i, _) -> w & changeSwapOther ispCloseItem 3 f i
-- Just (5, i, _) -> w & changeSwapOther ispCloseButton 5 f i
-- _ -> w
invSetSelection :: Selection -> World -> World
invSetSelection sel w =
w
@@ -200,15 +186,7 @@ invSetSelection sel w =
& cWorld . lWorld %~ crUpdateItemLocations 0
invSetSelectionPos :: Int -> Int -> World -> World
invSetSelectionPos i j w =
w
& hud . diSelection %~ f
& worldEventFlags . at InventoryChange ?~ ()
& setInvPosFromSS
& cWorld . lWorld %~ crUpdateItemLocations 0
where
f Nothing = Just (Sel i j mempty)
f (Just (Sel _ _ s)) = Just (Sel i j s)
invSetSelectionPos i j = invSetSelection (Sel i j mempty)
scrollAugInvSel :: Int -> World -> World
scrollAugInvSel yi w