Remove data Hammers

This commit is contained in:
2024-12-31 12:42:03 +00:00
parent 9e2dc995e9
commit 17da9e00f8
15 changed files with 146 additions and 166 deletions
+37 -46
View File
@@ -15,14 +15,14 @@ import Dodge.HeldUse
--import Dodge.Hotkey
import Dodge.Inventory
import Dodge.Item.Grammar
import Dodge.Item.Location
--import Dodge.Item.Location
import qualified IntMapHelp as IM
useItem :: Int -> PressType -> World -> World
useItem invid pt w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
cr <- w ^? cWorld . lWorld . creatures . ix 0
itmloc <- allInvLocs (_crInv cr) ^? ix invid . _2
usedloc <- useLocation' itmloc
usedloc <- useLocation itmloc
useItemLoc cr usedloc pt w
useItemLoc :: Creature -> LocationLDT ItemLink ComposedItem -> PressType
@@ -30,15 +30,15 @@ useItemLoc :: Creature -> LocationLDT ItemLink ComposedItem -> PressType
useItemLoc cr loc pt w = case loc ^. locLDT . ldtValue . _2 of
HeldPlatformSF ->
return $
heldEffect (bimap _iatType (^. _1) ldt) cr w
& pointerToItem itm . itUse . heldHammer .~ HammerDown
heldEffect pt (bimap _iatType (^. _1) ldt) cr w
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
GadgetPlatformSF ->
return $
heldEffect (bimap _iatType (^. _1) ldt) cr w
& pointerToItem itm . itUse . heldHammer .~ HammerDown
heldEffect pt (bimap _iatType (^. _1) ldt) cr w
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
RemoteDetonatorSF -> do
return $ activateDetonator ldt w
& pointerToItem itm . itUse . heldHammer .~ HammerDown
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
_ | isJust $ itm ^? itUse . uequipEffect -> do
invid' <- itm ^? itLocation . ilInvID
return $ toggleEquipmentAt invid' cr w
@@ -47,9 +47,9 @@ useItemLoc cr loc pt w = case loc ^. locLDT . ldtValue . _2 of
ldt = loc ^. locLDT
itm = ldt ^. ldtValue . _1
useLocation' :: LocationLDT ItemLink ComposedItem
useLocation :: LocationLDT ItemLink ComposedItem
-> Maybe (LocationLDT ItemLink ComposedItem)
useLocation' loc
useLocation loc
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uequipEffect = return loc
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uaParams . apLinkedProjectile . _Just
= return loc
@@ -57,34 +57,34 @@ useLocation' loc
= return loc
| otherwise = return $ locToTop loc
useSelectedItem :: Int -> World -> World
useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
cr <- w ^? cWorld . lWorld . creatures . ix crid
invid <- cr ^? crManipulation . manObject . imSelectedItem
itmloc <- allInvLocs (_crInv cr) ^? ix invid . _2
let usedloc = case useLocation itmloc of
UseFromLocation -> itmloc ^. locLDT
UseFromRoot -> locToTop itmloc ^. locLDT
let itm = usedloc ^. ldtValue . _1
case usedloc ^. ldtValue . _2 of
HeldPlatformSF ->
return $
heldEffect (bimap _iatType fst3 usedloc) cr w
& pointerToItem itm . itUse . heldHammer .~ HammerDown
GadgetPlatformSF ->
return $
heldEffect (bimap _iatType fst3 usedloc) cr w
& pointerToItem itm . itUse . heldHammer .~ HammerDown
RemoteDetonatorSF -> do
return $ activateDetonator usedloc w
& pointerToItem itm . itUse . heldHammer .~ HammerDown
_ | isJust $ itm ^? itUse . uequipEffect -> do
-- guard (_crHammerPosition cr == HammerUp)
invid' <- itm ^? itLocation . ilInvID
return $ toggleEquipmentAt invid' cr w
_ -> Nothing
where
fst3 (x, _, _) = x
--useSelectedItem :: Int -> World -> World
--useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
-- cr <- w ^? cWorld . lWorld . creatures . ix crid
-- invid <- cr ^? crManipulation . manObject . imSelectedItem
-- itmloc <- allInvLocs (_crInv cr) ^? ix invid . _2
-- let usedloc = case useLocation itmloc of
-- UseFromLocation -> itmloc ^. locLDT
-- UseFromRoot -> locToTop itmloc ^. locLDT
-- let itm = usedloc ^. ldtValue . _1
-- case usedloc ^. ldtValue . _2 of
-- HeldPlatformSF ->
-- return $
-- heldEffect (bimap _iatType fst3 usedloc) cr w
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
-- GadgetPlatformSF ->
-- return $
-- heldEffect (bimap _iatType fst3 usedloc) cr w
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
-- RemoteDetonatorSF -> do
-- return $ activateDetonator usedloc w
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
-- _ | isJust $ itm ^? itUse . uequipEffect -> do
---- guard (_crHammerPosition cr == HammerUp)
-- invid' <- itm ^? itLocation . ilInvID
-- return $ toggleEquipmentAt invid' cr w
-- _ -> Nothing
-- where
-- fst3 (x, _, _) = x
activateDetonator ::
LabelDoubleTree ItemLink ComposedItem ->
@@ -94,15 +94,6 @@ activateDetonator det = fromMaybe id $ do
pjid <- det ^? ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0
return $ cWorld . lWorld . projectiles . ix pjid . pjTimer .~ 0
useLocation :: LocationLDT ItemLink ComposedItem -> UseFocus
useLocation loc
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uequipEffect = UseFromLocation
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uaParams . apLinkedProjectile . _Just =
UseFromLocation
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0 =
UseFromLocation
| otherwise = UseFromRoot
toggleEquipmentAt :: Int -> Creature -> World -> World
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
DoNotMoveEquipment -> w
+3 -6
View File
@@ -21,7 +21,6 @@ import Dodge.Data.DoubleTree
import Dodge.Data.World
import Dodge.DoubleTree
import Dodge.Euse
import Dodge.Hammer
import Dodge.ItEffect
import Dodge.Item.Grammar
import Dodge.Item.HeldOffset
@@ -123,9 +122,7 @@ poisonSPic = over _1 $ overColSH (mixColors 0.5 0.5 green . normalizeColor)
internalCreatureUpdate :: Creature -> World -> World
internalCreatureUpdate cr =
cWorld . lWorld . creatures . ix (_crID cr)
%~ ( --(crHammerPosition %~ moveHammerUp).
updateMovement
)
%~ updateMovement
{- | Drop items according to the creature state.
TODO make sure this doesn't mess up any ItemPosition
@@ -432,10 +429,10 @@ itemUpdate = itUse %~ useUpdate
useUpdate :: ItemUse -> ItemUse
useUpdate =
(heldHammer %~ moveHammerUp)
-- (heldHammer %~ moveHammerUp)
-- . (leftHammer %~ moveHammerUp)
-- . (leftDelay . rateTime %~ decreaseToZero)
. (heldDelay . warmTime %~ decreaseToZero)
(heldDelay . warmTime %~ decreaseToZero)
. (heldDelay . rateTime %~ decreaseToZero)
--updateAutoRecharge :: Item -> Item
+8 -9
View File
@@ -43,19 +43,20 @@ handleHotkeys w
|| SDL.ScancodeRShift `M.member` _pressedKeys (_input w) =
foldl' tryAssignHotkey w allHotkeys
| otherwise =
foldl'
M.foldl'
useHotkey
w
(M.intersection thehotkeys (M.filter (== InitialPress) (w ^. input . pressedKeys)))
(M.intersectionWith (,) thehotkeys (w ^. input . pressedKeys))
where
thehotkeys = M.mapKeys hotkeyToScancode $ w ^. cWorld . lWorld . hotkeys
useHotkey :: World -> NewInt ItmInt -> World
useHotkey w (NInt itid) = fromMaybe w $ do
useHotkey :: World -> (NewInt ItmInt,PressType) -> World
useHotkey w (NInt itid,pt) = fromMaybe w $ do
invid <- w ^? cWorld . lWorld . itemLocations . ix itid . ilInvID
cr <- w ^? cWorld . lWorld . creatures . ix 0
itmloc <- allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT
return $ heldEffectNoHammerCheck (bimap (^. iatType) (^. _1) itmloc) cr w
return $ useItem invid pt w
-- cr <- w ^? cWorld . lWorld . creatures . ix 0
-- itmloc <- allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT
-- return $ heldEffectNoHammerCheck (bimap (^. iatType) (^. _1) itmloc) cr w
allHotkeys :: [SDL.Scancode]
allHotkeys = map hotkeyToScancode [minBound .. maxBound]
@@ -176,8 +177,6 @@ pressedMBEffectsTopInventory pkeys w
| Just ltime <- pkeys ^? ix SDL.ButtonLeft
, Just rtime <- pkeys ^? ix SDL.ButtonRight
, ltime <= rtime && inTopInv =
--youhammerdown $
--useSelectedItem 0 w
fromMaybe w $ do
invid <- w ^? cWorld . lWorld . creatures . ix 0
. crManipulation . manObject . imSelectedItem