Start refactor storing items in single intmap, done turrets

More checks required
This commit is contained in:
2025-08-24 11:53:21 +01:00
parent 7336177edf
commit c38d03165f
22 changed files with 642 additions and 269 deletions
+2 -2
View File
@@ -37,7 +37,7 @@ pointerYourRootItem f w = fromMaybe (pure w) $ do
pointerToItem :: Applicative f => Item -> (Item -> f Item) -> World -> f World
pointerToItem x = case x ^. itLocation of
OnFloor -> cWorld . lWorld . floorItems . ix (x ^. itID . unNInt) . flIt
OnTurret tid -> cWorld . lWorld . machines . ix tid . mcType . mctTurret . tuWeapon
OnTurret _ -> cWorld . lWorld . items . ix (x ^. itID . unNInt)
InInv cid invid _ _ _ _ -> cWorld . lWorld . creatures . ix cid . crInv . ix invid
InVoid -> const pure
@@ -46,6 +46,6 @@ pointerToItemID itid f w = fromMaybe (pure w) $ do
itloc <- w ^? cWorld . lWorld . itemLocations . ix (_unNInt itid)
return $ (\x -> x f w) $ case itloc of
OnFloor -> cWorld . lWorld . floorItems . ix (_unNInt itid) . flIt
OnTurret tid -> cWorld . lWorld . machines . ix tid . mcType . mctTurret . tuWeapon
OnTurret _ -> cWorld . lWorld . items . ix (itid ^. unNInt)
InInv cid invid _ _ _ _ -> cWorld . lWorld . creatures . ix cid . crInv . ix invid
InVoid -> const pure