Refactor floor items, removing ids (not fully checked)

This commit is contained in:
2025-08-23 22:10:33 +01:00
parent 32d7120177
commit fcccd63844
24 changed files with 94 additions and 109 deletions
+3 -3
View File
@@ -66,9 +66,9 @@ destroyItem itid w = case w ^? cWorld . lWorld . itemLocations . ix itid of
Nothing -> error $ "Tried to destroy item that does not exist; item id: " ++ show itid
Just InInv{_ilCrID = cid, _ilInvID = invid} -> destroyInvItem cid invid w
Just OnTurret{} -> error "need to write code for destroying items on turrets"
Just (OnFloor (NInt i)) ->
Just OnFloor ->
w & cWorld . lWorld . itemLocations . at itid .~ Nothing
& cWorld . lWorld . floorItems . unNIntMap . at i .~ Nothing
& cWorld . lWorld . floorItems . at itid .~ Nothing
Just InVoid -> w & cWorld . lWorld . itemLocations . at itid .~ Nothing
-- note rmInvItem does not fully destroy the item, other updates to the item
@@ -125,7 +125,7 @@ updateCloseObjects w =
g oldbts = intersect oldbts cbts `union` cbts
f olditems = intersect olditems citems `union` citems
lw = w ^. cWorld . lWorld
citems = lw^..floorItems . unNIntMap . each . filtered (isclose . _flItPos) . to _flItID
citems = lw^..floorItems . each . filtered (isclose . _flItPos) . to (_itID . _flIt)
isclose x = dist y x < 40 && hasButtonLOS y x w
y = _crPos $ you w
cbts = lw^..buttons . each . filtered canpress . filtered (isclose . _btPos) . to _btID