Fix bug in creature death drop/destruction ordering
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
--{-# LANGUAGE TupleSections #-}
|
||||
module Dodge.Inventory (
|
||||
checkInvSlotsYou,
|
||||
rmSelectedInvItem,
|
||||
rmInvItem,
|
||||
destroyInvItem,
|
||||
updateCloseObjects,
|
||||
@@ -59,7 +58,6 @@ rmInvItem ::
|
||||
World ->
|
||||
World
|
||||
rmInvItem cid invid w = w
|
||||
-- & pointcid %~ crCancelReloading
|
||||
& doanyitemeffect
|
||||
& dounequipfunction --the ordering of these is
|
||||
& pointcid . crInv %~ f -- important
|
||||
@@ -110,85 +108,6 @@ rmInvItem cid invid w = w
|
||||
| x > invid || Just x == maxk = max 0 $ x - 1
|
||||
| otherwise = x
|
||||
|
||||
--updateCreatureItemLocations :: Int -> World -> World
|
||||
--updateCreatureItemLocations crid w = fromMaybe w $ do
|
||||
-- inv <- w ^? cWorld . lWorld . creatures . ix crid . crInv
|
||||
-- return $ foldl' updateItemLocation w inv
|
||||
--
|
||||
--updateItemLocation :: World -> Item -> World
|
||||
--updateItemLocation w itm = w
|
||||
-- & cWorld . lWorld . itemLocations . ix (itm ^. itID) .~ itm ^. itLocation
|
||||
|
||||
---- | after this the item at the inventory position will no longer exist
|
||||
--rmInvItem ::
|
||||
-- -- | Creature id
|
||||
-- Int ->
|
||||
-- -- | Inventory position
|
||||
-- Int ->
|
||||
-- World ->
|
||||
-- World
|
||||
--rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount of
|
||||
-- Just x
|
||||
-- | x > 1 ->
|
||||
-- w & pointcid . crInv . ix invid . itUse . useAmount -~ 1
|
||||
-- & worldEventFlags . at InventoryChange ?~ ()
|
||||
-- _ ->
|
||||
-- w
|
||||
---- & pointcid %~ crCancelReloading
|
||||
-- & doanyitemeffect
|
||||
-- & dounequipfunction --the ordering of these is
|
||||
-- & pointcid . crInv %~ f -- important
|
||||
--
|
||||
-- & removeAnySlotEquipment
|
||||
-- & pointcid . crEquipment . each %~ g
|
||||
-- & pointcid . crInvEquipped %~ IM.delete invid
|
||||
-- & pointcid . crInvEquipped %~ IM.mapKeys g
|
||||
--
|
||||
-- & removeanyactivation
|
||||
-- & pointcid . crHotkeys . each %~ g
|
||||
-- & pointcid . crInvHotkeys %~ IM.delete invid
|
||||
-- & pointcid . crInvHotkeys %~ IM.mapKeys g
|
||||
--
|
||||
-- & updateselection
|
||||
-- & worldEventFlags . at InventoryChange ?~ ()
|
||||
-- where
|
||||
-- getcid = cWorld . lWorld . creatures . ix cid
|
||||
-- pointcid = cWorld . lWorld . creatures . ix cid
|
||||
--
|
||||
-- updateselection
|
||||
-- | cid == 0 && cr ^? crManipulation . manObject . inInventory . ispItem == Just invid =
|
||||
-- scrollAugInvSel (-1) . scrollAugInvSel 1 . updateInventorySectionItems
|
||||
-- | otherwise =
|
||||
-- pointcid . crManipulation . manObject . inInventory . ispItem %~ g
|
||||
--
|
||||
-- cr = w ^?! cWorld . lWorld . creatures . ix cid
|
||||
-- itm = _crInv cr IM.! invid
|
||||
-- dounequipfunction = fromMaybe id $ do
|
||||
-- rmf <- itm ^? itUse . equipEffect . eeOnRemove
|
||||
-- return $ useE rmf itm cr
|
||||
-- doanyitemeffect = fromMaybe id $ do
|
||||
-- rmf <- itm ^? itEffect . ieOnDrop
|
||||
-- return $ doInvEffect rmf itm cr
|
||||
-- removeAnySlotEquipment = fromMaybe id $ do
|
||||
-- epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvEquipped . ix invid
|
||||
-- return $ pointcid . crEquipment . at epos .~ Nothing
|
||||
-- removeanyactivation = fromMaybe id $ do
|
||||
-- epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvHotkeys . ix invid
|
||||
-- return $ pointcid . crHotkeys . at epos .~ Nothing
|
||||
-- maxk = fmap fst $ IM.lookupMax $ cr ^. crInv
|
||||
-- f inv =
|
||||
-- let (xs, ys) = IM.split invid inv
|
||||
-- in xs `IM.union` IM.mapKeysMonotonic (subtract 1) ys
|
||||
-- -- the following might not work if a non-player creature drops their last item
|
||||
-- g x
|
||||
-- | x > invid || Just x == maxk = max 0 $ x - 1
|
||||
-- | otherwise = x
|
||||
|
||||
rmSelectedInvItem :: Int -> World -> World
|
||||
rmSelectedInvItem cid w = case w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . imSelectedItem of
|
||||
Just i -> rmInvItem cid i w
|
||||
Nothing -> w
|
||||
|
||||
-- this looks ugly...
|
||||
updateCloseObjects :: World -> World
|
||||
updateCloseObjects w =
|
||||
|
||||
Reference in New Issue
Block a user