Add in "linear" lWorld to separate time reversable worlds

This commit is contained in:
2022-10-28 12:24:51 +01:00
parent 5f6bd43599
commit 7e790b7153
130 changed files with 827 additions and 980 deletions
+14 -14
View File
@@ -9,24 +9,24 @@ initItemLocations :: CWorld -> CWorld
initItemLocations = initCrsItemLocations . initFlItemsLocations . initTusItemLocations
initCrsItemLocations :: CWorld -> CWorld
initCrsItemLocations w = w' & creatures .~ newcreatures
initCrsItemLocations w = w' & lWorld . creatures .~ newcreatures
where
(w', newcreatures) = mapAccumR initCrItemLocations w (_creatures w)
(w', newcreatures) = mapAccumR initCrItemLocations w (w ^. lWorld . creatures)
initFlItemsLocations :: CWorld -> CWorld
initFlItemsLocations w = w' & floorItems .~ newfloorItems
initFlItemsLocations w = w' & lWorld . floorItems .~ newfloorItems
where
(w', newfloorItems) = mapAccumR initFlItemLocation w (_floorItems w)
(w', newfloorItems) = mapAccumR initFlItemLocation w (w ^. lWorld . floorItems)
initTusItemLocations :: CWorld -> CWorld
initTusItemLocations w = w' & machines .~ newmachines
initTusItemLocations w = w' & lWorld . machines .~ newmachines
where
(w', newmachines) = mapAccumR initTuItemLocation w (_machines w)
(w', newmachines) = mapAccumR initTuItemLocation w (w ^. lWorld . machines)
initSpecificCrItemLocations :: Int -> CWorld -> CWorld
initSpecificCrItemLocations crid w = w' & creatures . ix crid .~ newcr
initSpecificCrItemLocations crid w = w' & lWorld . creatures . ix crid .~ newcr
where
(w',newcr) = initCrItemLocations w (w ^?! creatures . ix crid)
(w',newcr) = initCrItemLocations w (w ^?! lWorld . creatures . ix crid)
initCrItemLocations :: CWorld -> Creature -> (CWorld, Creature)
initCrItemLocations w cr = (w', cr & crInv .~ newinv)
@@ -34,30 +34,30 @@ initCrItemLocations w cr = (w', cr & crInv .~ newinv)
(w',newinv) = imapAccumR (initCrItemLocation cr) w (_crInv cr)
initCrItemLocation :: Creature -> Int -> CWorld -> Item -> (CWorld,Item)
initCrItemLocation cr invid w it = (w & itemLocations . at locid ?~ loc
initCrItemLocation cr invid w it = (w & lWorld . itemLocations . at locid ?~ loc
,it & itID .~ locid
& itLocation .~ loc)
where
locid = IM.newKey (_itemLocations w)
locid = IM.newKey ( w ^. lWorld . itemLocations)
loc = InInv (_crID cr) invid
initFlItemLocation :: CWorld -> FloorItem -> (CWorld, FloorItem)
initFlItemLocation w flit = (w & itemLocations . at locid ?~ loc
initFlItemLocation w flit = (w & lWorld . itemLocations . at locid ?~ loc
, flit & flIt . itID .~ locid
& flIt . itLocation .~ loc
)
where
locid = IM.newKey (_itemLocations w)
locid = IM.newKey (w ^. lWorld . itemLocations )
loc = OnFloor (_flItID flit)
initTuItemLocation :: CWorld -> Machine -> (CWorld, Machine)
initTuItemLocation w mc = case mc ^? mcType . _McTurret . tuWeapon of
Nothing -> (w, mc)
Just _ ->
let locid = IM.newKey (_itemLocations w)
let locid = IM.newKey ( w ^. lWorld . itemLocations)
loc = OnTurret (_mcID mc)
in ( w & itemLocations . at locid ?~ loc
in ( w & lWorld . itemLocations . at locid ?~ loc
, mc & mcType . _McTurret . tuWeapon . itID .~ locid
& mcType . _McTurret . tuWeapon . itLocation .~ loc
)