Make all items have an id an associated location
This commit is contained in:
@@ -11,7 +11,7 @@ setHeldItemLoc cr = fst . getHeldItemLoc cr
|
||||
getHeldItemLoc :: Creature -> World -> (World, Int)
|
||||
getHeldItemLoc cr w = case maybeitid of
|
||||
Nothing ->
|
||||
( w & cWorld . creatures . ix cid . crInv . ix j . itID ?~ newitid
|
||||
( w & cWorld . creatures . ix cid . crInv . ix j . itID .~ newitid
|
||||
& cWorld . itemLocations %~ IM.insert newitid (InInv cid j)
|
||||
, itid
|
||||
)
|
||||
@@ -20,7 +20,7 @@ getHeldItemLoc cr w = case maybeitid of
|
||||
cid = _crID cr
|
||||
j = crSel cr
|
||||
newitid = IM.newKey $ _itemLocations (_cWorld w)
|
||||
maybeitid = cr ^? crInv . ix j . itID . _Just
|
||||
maybeitid = cr ^? crInv . ix j . itID
|
||||
itid = fromMaybe newitid maybeitid
|
||||
|
||||
getItem :: Int -> World -> Maybe Item
|
||||
@@ -29,7 +29,8 @@ getItem itid w = do
|
||||
case itpos of
|
||||
OnFloor flitid -> w ^? cWorld . floorItems . ix flitid . flIt
|
||||
InInv cid invid -> w ^? cWorld . creatures . ix cid . crInv . ix invid
|
||||
VoidItm -> Nothing
|
||||
OnTurret mcid -> w ^? cWorld . machines . ix mcid . mcType . _McTurret . tuWeapon
|
||||
InVoid -> Nothing
|
||||
|
||||
pointerToItemLocation ::
|
||||
Applicative f =>
|
||||
|
||||
Reference in New Issue
Block a user