Add in "linear" lWorld to separate time reversable worlds
This commit is contained in:
@@ -21,11 +21,11 @@ import qualified SDL
|
||||
|
||||
useItem :: Creature -> World -> World
|
||||
useItem cr' w = fromMaybe (f w) $ do
|
||||
cr <- w ^? cWorld . creatures . ix (_crID cr')
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
||||
it <- cr ^? crInv . ix (crSel cr)
|
||||
return $ itemEffect cr it w
|
||||
where
|
||||
f = cWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||
f = cWorld . lWorld . creatures . ix (_crID cr') . crHammerPosition .~ HammerDown
|
||||
|
||||
itemEffect :: Creature -> Item -> World -> World
|
||||
itemEffect cr it w = case it ^. itUse of
|
||||
@@ -41,7 +41,7 @@ itemEffect cr it w = case it ^. itUse of
|
||||
hammerTest f = case _crHammerPosition cr of
|
||||
HammerUp -> f w
|
||||
_ -> w & setuhamdown
|
||||
setuhamdown = cWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
||||
setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
||||
doequipmentchange =
|
||||
setuhamdown $
|
||||
hammerTest
|
||||
@@ -51,7 +51,7 @@ itemEffect cr it w = case it ^. itUse of
|
||||
|
||||
tryReload :: Creature -> Item -> World -> (World -> World) -> World -> World
|
||||
tryReload cr it w f
|
||||
| _crID cr == _yourID (_cWorld w) && itNeedsLoading it && _mouseButtons w M.!? SDL.ButtonLeft == Just False =
|
||||
| _crID cr == (w ^. cWorld . lWorld . yourID) && itNeedsLoading it && _mouseButtons w M.!? SDL.ButtonLeft == Just False =
|
||||
crToggleReloading cr
|
||||
| otherwise =
|
||||
(runIdentity . pointerToItemLocation (_itLocation it) (return . (itUse . heldHammer .~ HammerDown)))
|
||||
@@ -64,7 +64,7 @@ itNeedsLoading it = _laLoaded ic == 0 || not (_laPrimed ic)
|
||||
|
||||
activateEquipmentAt :: RightButtonOptions -> Creature -> World -> World
|
||||
activateEquipmentAt rbo cr =
|
||||
cWorld . creatures . ix (_crID cr) %~ case (rbo ^? opActivateEquipment . activateEquipment, rbo ^? opActivateEquipment . deactivateEquipment) of
|
||||
cWorld . lWorld . creatures . ix (_crID cr) %~ case (rbo ^? opActivateEquipment . activateEquipment, rbo ^? opActivateEquipment . deactivateEquipment) of
|
||||
(Just i, _) -> crLeftInvSel ?~ i
|
||||
(_, Just _) -> crLeftInvSel .~ Nothing
|
||||
_ -> id
|
||||
@@ -102,7 +102,7 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
|
||||
& onremove itm cr
|
||||
Nothing -> error "tried to toggle equipment whilst not prepared"
|
||||
where
|
||||
crpoint = cWorld . creatures . ix (_crID cr)
|
||||
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
||||
itmat i = _crInv cr IM.! i
|
||||
itm = itmat (crSel cr)
|
||||
onequip itm' = useE ((_eeOnEquip . _equipEffect . _itUse) itm') itm'
|
||||
@@ -122,7 +122,7 @@ useLeftItem cid w
|
||||
. useL f itm cr
|
||||
$ w
|
||||
where
|
||||
cr = _creatures (_cWorld w) IM.! cid
|
||||
cr = w ^?! cWorld . lWorld . creatures . ix cid-- _creatures (_cWorld w) IM.! cid
|
||||
itmIsConsumable =
|
||||
isJust (cr ^? crInv . ix (crSel cr) . itUse . cUse)
|
||||
itmIsEquipable =
|
||||
|
||||
Reference in New Issue
Block a user