Fix at least one bug from item refactor, more remain

This commit is contained in:
2025-08-24 21:01:02 +01:00
parent 94f6d5c630
commit c2daa86463
19 changed files with 95 additions and 95 deletions
+13 -17
View File
@@ -1,36 +1,32 @@
module Dodge.FloorItem (
copyItemToFloor,
copyItemToFloorID,
-- copyItemToFloorID,
) where
import Dodge.Item.InvSize
import NewInt
import Control.Lens
import Data.Maybe
import Data.Monoid
import Dodge.Base
import Dodge.Data.World
import Dodge.Item.InvSize
import Geometry
import qualified IntMapHelp as IM
--import qualified IntMapHelp as IM
import NewInt
import System.Random
-- | Copy an item to the floor.
-- | Copy an item to the floor
copyItemToFloor :: Point2 -> Item -> World -> World
copyItemToFloor pos it = copyItemToFloorID pos it
-- | Copy an item to the floor, returns the floor item's id.
copyItemToFloorID :: Point2 -> Item -> World -> World
copyItemToFloorID pos it w =
w'
& cWorld . lWorld . floorItems %~ IM.insert (_unNInt $ _itID it) theflit
& cWorld . lWorld . items . ix (_unNInt $ _itID it) . itLocation .~ 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
copyItemToFloor pos it w =
w'
& cWorld . lWorld . floorItems . at (_unNInt $ _itID it) ?~ theflit
& cWorld . lWorld . items . at (_unNInt $ _itID it) ?~ (it & itLocation .~ OnFloor)
& hud . closeItems %~ (_itID it :)
where
-- & hud . hudElement . diSections . ix 3 . ssOffset .~ 0
-- ensures dropped item is at the top of the close item selection list
(p', w') = findWallFreeDropPoint (_dimRad $ itDim it) pos w
rot = fst . randomR (- pi, pi) $ _randGen w
theflit = FlIt { _flItPos = p' , _flItRot = rot }
theflit = FlIt{_flItPos = p', _flItRot = rot}
cardinalVectors :: [Point2]
cardinalVectors =