Improve item location code
This commit is contained in:
@@ -15,7 +15,7 @@ module Dodge.Creature.Action (
|
||||
copyInvItemToFloor,
|
||||
youDropItem,
|
||||
pickUpItem,
|
||||
pickUpItemID,
|
||||
-- pickUpItemID,
|
||||
) where
|
||||
|
||||
import Control.Applicative
|
||||
@@ -210,8 +210,6 @@ copyInvItemToFloor :: Creature -> Int -> World -> World
|
||||
copyInvItemToFloor cr i =
|
||||
copyItemToFloor (_crPos cr) $
|
||||
_crInv cr IM.! i
|
||||
& itIsSelected .~ False
|
||||
& itIsRoot .~ False
|
||||
|
||||
sizeSelf :: Float -> Creature -> World -> Maybe World
|
||||
sizeSelf x cr w
|
||||
@@ -236,11 +234,3 @@ sizeSelf x cr w
|
||||
cid = _crID cr
|
||||
cpos = _crPos cr
|
||||
|
||||
pickUpItemID :: Int -> Int -> World -> World
|
||||
pickUpItemID cid flid w = pickUpItem cid (w ^?! cWorld . lWorld . floorItems . ix flid) w
|
||||
|
||||
-- | Pick up a specific item.
|
||||
pickUpItem :: Int -> FloorItem -> World -> World
|
||||
pickUpItem cid flit w =
|
||||
maybe w (soundStart (CrSound cid) (_flItPos flit) pickUpS Nothing . snd) $
|
||||
tryPutItemInInv cid flit w
|
||||
|
||||
@@ -47,7 +47,7 @@ itemEffect cr it w = case it ^. ldtValue . itUse of
|
||||
itm = it ^. ldtValue
|
||||
doequipmentchange = fromMaybe w $ do
|
||||
guard (_crHammerPosition cr == HammerUp)
|
||||
invid <- itm ^? itLocation . ipInvID
|
||||
invid <- itm ^? itLocation . ilInvID
|
||||
return $ toggleEquipmentAt invid cr w
|
||||
|
||||
toggleEquipmentAt :: Int -> Creature -> World -> World
|
||||
|
||||
@@ -248,10 +248,10 @@ invSideEff cr w =
|
||||
|
||||
itemInvSideEffect :: Creature -> Item -> World -> World
|
||||
itemInvSideEffect cr it
|
||||
| hastorchattach = createAttachLight cr it
|
||||
-- | hastorchattach = createAttachLight cr it
|
||||
| otherwise = id
|
||||
where
|
||||
hastorchattach = it ^? itType . iyModules . ix ModHeldAttach == Just ATTACHTORCH && _itIsRoot it
|
||||
-- hastorchattach = it ^? itType . iyModules . ix ModHeldAttach == Just ATTACHTORCH && _itIsRoot it
|
||||
|
||||
createAttachLight :: Creature -> Item -> World -> World
|
||||
createAttachLight cr it = createTorchLightOffset cr it attachoff
|
||||
@@ -262,9 +262,9 @@ itemUpdate :: Creature -> Int -> Item -> Item
|
||||
itemUpdate cr i =
|
||||
updateAutoRecharge
|
||||
. (itUse %~ useUpdate)
|
||||
. (itLocation .~ InInv (_crID cr) i)
|
||||
. (itIsRoot .~ itmisroot)
|
||||
. (itIsSelected .~ itmisselected)
|
||||
. (itLocation .~ InInv (_crID cr) i itmisselected itmisroot)
|
||||
-- . (itIsRoot .~ itmisroot)
|
||||
-- . (itIsSelected .~ itmisselected)
|
||||
where
|
||||
itmisroot = Just i == (cr ^? crManipulation . manObject . inInventory . imRootItem)
|
||||
itmisselected = Just i == (cr ^? crManipulation . manObject . inInventory . imSelectedItem)
|
||||
|
||||
Reference in New Issue
Block a user