Refactor floor items, removing ids (not fully checked)
This commit is contained in:
@@ -16,28 +16,25 @@ import System.Random
|
||||
|
||||
-- | Copy an item to the floor.
|
||||
copyItemToFloor :: Point2 -> Item -> World -> World
|
||||
copyItemToFloor pos it = snd . copyItemToFloorID pos it
|
||||
copyItemToFloor pos it = copyItemToFloorID pos it
|
||||
|
||||
-- | Copy an item to the floor, returns the floor item's id.
|
||||
copyItemToFloorID :: Point2 -> Item -> World -> (NewInt FloorInt, World)
|
||||
copyItemToFloorID :: Point2 -> Item -> World -> World
|
||||
copyItemToFloorID pos it w =
|
||||
(,) (NInt flid) $
|
||||
w'
|
||||
& cWorld . lWorld . floorItems . unNIntMap %~ IM.insert flid theflit
|
||||
& cWorld . lWorld . itemLocations %~ IM.insert (_unNInt $ _itID it) (OnFloor $ NInt flid)
|
||||
& hud . closeItems %~ (NInt flid:)
|
||||
& cWorld . lWorld . floorItems %~ IM.insert (_unNInt $ _itID it) theflit
|
||||
& cWorld . lWorld . itemLocations %~ IM.insert (_unNInt $ _itID it) OnFloor
|
||||
& hud . closeItems %~ (_itID it:)
|
||||
-- & hud . hudElement . diSections . ix 3 . ssOffset .~ 0
|
||||
-- ensures dropped item is at the top of the close item selection list
|
||||
where
|
||||
(p', w') = findWallFreeDropPoint (_dimRad $ itDim it) pos w
|
||||
rot = fst . randomR (- pi, pi) $ _randGen w
|
||||
flid = IM.newKey . _unNIntMap . _floorItems . _lWorld $ _cWorld w
|
||||
theflit =
|
||||
FlIt
|
||||
{ _flIt = it & itLocation .~ OnFloor (NInt flid)
|
||||
{ _flIt = it & itLocation .~ OnFloor
|
||||
, _flItPos = p'
|
||||
, _flItRot = rot
|
||||
, _flItID = NInt flid
|
||||
}
|
||||
|
||||
cardinalVectors :: [Point2]
|
||||
|
||||
Reference in New Issue
Block a user