Correctly reduce left click item delay

This commit is contained in:
2022-09-04 10:22:53 +01:00
parent 920bfdbc8e
commit 8c0ad639ad
9 changed files with 30 additions and 56 deletions
+5 -3
View File
@@ -110,7 +110,8 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
useLeftItem :: Int -> World -> World useLeftItem :: Int -> World -> World
useLeftItem cid w useLeftItem cid w
| _crInvLock cr = w | _crInvLock cr = w
| itmShouldBeUsed = useItem cr w -- I believe this ONLY sets equipment options | itmIsConsumable = useItem cr w -- I believe this ONLY sets equipment options
| itmIsEquipable = useItem cr w -- I believe this ONLY sets equipment options
| otherwise = fromMaybe w $ do | otherwise = fromMaybe w $ do
invid <- _crLeftInvSel cr invid <- _crLeftInvSel cr
itm <- cr ^? crInv . ix invid itm <- cr ^? crInv . ix invid
@@ -121,9 +122,10 @@ useLeftItem cid w
$ w $ w
where where
cr = _creatures (_cWorld w) IM.! cid cr = _creatures (_cWorld w) IM.! cid
itmShouldBeUsed = itmIsConsumable =
isJust (cr ^? crInv . ix (crSel cr) . itUse . cUse) isJust (cr ^? crInv . ix (crSel cr) . itUse . cUse)
|| ( isJust (cr ^? crInv . ix (crSel cr) . itUse . equipEffect . eeUse) itmIsEquipable =
( isJust (cr ^? crInv . ix (crSel cr) . itUse . equipEffect . eeUse)
&& _crLeftInvSel cr /= Just (crSel cr) && _crLeftInvSel cr /= Just (crSel cr)
) )
+1
View File
@@ -147,6 +147,7 @@ newExtraAwareness ::
Int -> Int ->
Maybe Awareness Maybe Awareness
newExtraAwareness cr w cid newExtraAwareness cr w cid
| dist cpos tpos > 600 = Nothing
| not $ canSeeIndirect (_crID cr) cid w = Nothing | not $ canSeeIndirect (_crID cr) cid w = Nothing
| otherwise = Just . Suspicious $ doFloatFloat (_viFOV vi) ang * doFloatFloat (_viDist vi) d * awakeLevelPerception cr | otherwise = Just . Suspicious $ doFloatFloat (_viFOV vi) ang * doFloatFloat (_viDist vi) d * awakeLevelPerception cr
where where
+2
View File
@@ -202,6 +202,8 @@ movementSideEff cr w
useUpdate :: ItemUse -> ItemUse useUpdate :: ItemUse -> ItemUse
useUpdate = useUpdate =
(heldHammer %~ moveHammerUp) (heldHammer %~ moveHammerUp)
. (leftHammer %~ moveHammerUp)
. (leftDelay . rateTime %~ decreaseToZero)
. (heldDelay . warmTime %~ decreaseToZero) . (heldDelay . warmTime %~ decreaseToZero)
. (heldDelay . rateTime %~ decreaseToZero) . (heldDelay . rateTime %~ decreaseToZero)
+2
View File
@@ -3,6 +3,7 @@ Rexports all Dodge.Data.x files.
-} -}
module Dodge.Data ( module Dodge.Data (
module Dodge.Data.World, module Dodge.Data.World,
module Dodge.Data.Scenario,
module Dodge.Data.WorldEffect, module Dodge.Data.WorldEffect,
module Dodge.Data.ArcStep, module Dodge.Data.ArcStep,
module Dodge.Data.Config, module Dodge.Data.Config,
@@ -22,6 +23,7 @@ module Dodge.Data (
) where ) where
import Dodge.Data.Config import Dodge.Data.Config
import Dodge.Data.Scenario
import Dodge.Data.WorldEffect import Dodge.Data.WorldEffect
import Dodge.Data.ActionPlan import Dodge.Data.ActionPlan
import Dodge.Data.ArcStep import Dodge.Data.ArcStep
+1 -1
View File
@@ -65,7 +65,7 @@ doDrawing pdata u = do
windowPoints windowPoints
(_floorTiles (_cWorld w)) (_floorTiles (_cWorld w))
) )
( pokeShape' ( pokeShape
(_vboPtr $ _vaoVBO $ _shadVAO $ _shapeShader pdata) (_vboPtr $ _vaoVBO $ _shadVAO $ _shapeShader pdata)
(_eboPtr $ _shapeEBO pdata) (_eboPtr $ _shapeEBO pdata)
(_eboPtr $ _silhouetteEBO pdata) (_eboPtr $ _silhouetteEBO pdata)
+10 -1
View File
@@ -1,7 +1,16 @@
module Dodge.TestString where module Dodge.TestString where
import Dodge.Data.Universe import Dodge.Data.Universe
import Control.Lens
import Data.Maybe
testStringInit :: Universe -> [String] testStringInit :: Universe -> [String]
testStringInit _ = [] testStringInit u = [
show $ u ^? uvWorld . hammers . ix DoubleMouseHam
, show $ u ^? uvWorld . cWorld . creatures . ix 0 . crLeftInvSel . _Just
, fromMaybe "" $ do
i <- u ^? uvWorld . cWorld . creatures . ix 0 . crLeftInvSel . _Just
h <- u ^? uvWorld . cWorld . creatures . ix 0 . crInv . ix i . itUse . leftHammer
return $ show h
]
+1
View File
@@ -453,6 +453,7 @@ markWallSeen :: World -> Int -> World
markWallSeen !w !i = w & cWorld . walls .~ IM.adjust markSeen i (_walls (_cWorld w)) markWallSeen !w !i = w & cWorld . walls .~ IM.adjust markSeen i (_walls (_cWorld w))
markSeen :: Wall -> Wall markSeen :: Wall -> Wall
{-# INLINE markSeen #-}
markSeen wl = wl{_wlSeen = True} markSeen wl = wl{_wlSeen = True}
checkEndGame :: Universe -> Universe checkEndGame :: Universe -> Universe
+6 -6
View File
@@ -20,16 +20,16 @@ import SDL
updateUsingInput :: World -> World updateUsingInput :: World -> World
updateUsingInput w = case _hudElement $ _hud (_cWorld w) of updateUsingInput w = case _hudElement $ _hud (_cWorld w) of
DisplayInventory subinv -> DisplayInventory subinv ->
updatePressedButtons subinv (_mouseButtons w) w pressedMBEffects subinv (_mouseButtons w) w
DisplayCarte -> DisplayCarte ->
updatePressedButtonsCarte (_mouseButtons w) w updatePressedButtonsCarte (_mouseButtons w) w
updatePressedButtons :: SubInventory -> M.Map MouseButton Bool -> World -> World pressedMBEffects :: SubInventory -> M.Map MouseButton Bool -> World -> World
updatePressedButtons subinv pkeys w = case subinv of pressedMBEffects subinv pkeys w = case subinv of
NoSubInventory NoSubInventory
| ButtonLeft `M.member` pkeys && w ^?! hammers . ix SubInvHam /= HammerUp -> | ButtonLeft `M.member` pkeys && w ^?! hammers . ix SubInvHam /= HammerUp ->
w & hammers . ix SubInvHam .~ HammerDown w & hammers . ix SubInvHam .~ HammerDown
| otherwise -> updatePressedButtons' pkeys w | otherwise -> pressedMBEffectsNoInventory pkeys w
CombineInventory mi CombineInventory mi
| pkeys ^? ix ButtonLeft == Just False -> | pkeys ^? ix ButtonLeft == Just False ->
maybeexitcombine (maybe id doCombine mi w) & hammers . ix SubInvHam .~ HammerDown maybeexitcombine (maybe id doCombine mi w) & hammers . ix SubInvHam .~ HammerDown
@@ -49,8 +49,8 @@ updatePressedButtons subinv pkeys w = case subinv of
| ButtonRight `M.member` _mouseButtons w = id | ButtonRight `M.member` _mouseButtons w = id
| otherwise = cWorld . hud . hudElement .~ DisplayInventory NoSubInventory | otherwise = cWorld . hud . hudElement .~ DisplayInventory NoSubInventory
updatePressedButtons' :: M.Map MouseButton Bool -> World -> World pressedMBEffectsNoInventory :: M.Map MouseButton Bool -> World -> World
updatePressedButtons' pkeys w pressedMBEffectsNoInventory pkeys w
| isDown ButtonLeft && isDown ButtonRight && inTopInv = | isDown ButtonLeft && isDown ButtonRight && inTopInv =
useItem (you w) w & hammers . ix DoubleMouseHam .~ HammerDown useItem (you w) w & hammers . ix DoubleMouseHam .~ HammerDown
| isDown ButtonLeft && (inTopInv || _timeFlow w == RewindingLastFrame) | isDown ButtonLeft && (inTopInv || _timeFlow w == RewindingLastFrame)
+2 -45
View File
@@ -1,11 +1,8 @@
module Shader.Poke module Shader.Poke
( pokeVerxs ( pokeVerxs
-- , pokeSPics
, pokeLayVerxs , pokeLayVerxs
, pokeArrayOff , pokeArrayOff
-- , pokePoint33s , pokeShape
-- , pokeShape
, pokeShape'
, pokeWallsWindowsFloor , pokeWallsWindowsFloor
) where ) where
import Shader.Data import Shader.Data
@@ -54,11 +51,8 @@ pokeWallsWindowsFloor
-> [ ( Point3 , Point3 ) ] -> [ ( Point3 , Point3 ) ]
-> IO (Int,Int,Int) -> IO (Int,Int,Int)
pokeWallsWindowsFloor wlptr wiptr flptr wls wis fls = do pokeWallsWindowsFloor wlptr wiptr flptr wls wis fls = do
--wlcounts1 <- S.foldM_ (pokeW wlptr) (return 0) return (S.each wls)
wlcounts1 <- VFSM.foldlM' (pokeW wlptr) 0 (VFSM.fromList wls) wlcounts1 <- VFSM.foldlM' (pokeW wlptr) 0 (VFSM.fromList wls)
--wlcounts2 <- S.foldM_ (pokeW wiptr) (return 0) return (S.each wis)
wlcounts2 <- VFSM.foldlM' (pokeW wiptr) 0 (VFSM.fromList wis) wlcounts2 <- VFSM.foldlM' (pokeW wiptr) 0 (VFSM.fromList wis)
--flcounts <- S.foldM_ (pokeF flptr) (return 0) return (S.each fls)
flcounts <- VFSM.foldlM' (pokeF flptr) 0 (VFSM.fromList fls) flcounts <- VFSM.foldlM' (pokeF flptr) 0 (VFSM.fromList fls)
return (wlcounts1,wlcounts2,flcounts) return (wlcounts1,wlcounts2,flcounts)
@@ -86,33 +80,11 @@ pokeW ptr i' ((V2 a b,V2 c d),V4 e f g h) = do
pokeElemOff ptr (i + 7) h pokeElemOff ptr (i + 7) h
return $ i' + 1 return $ i' + 1
--pokeSPics
-- :: MV.MVector (PrimState IO) FullShader
-- -> UMV.MVector (PrimState IO) Int
-- -> Ptr Float -> Ptr GLushort -> Ptr GLushort
-- -> Stream (Of SPic) IO ()
-- -> IO (Int,Int,Int)
--pokeSPics vbos counts ptr iptr ieptr =
-- S.foldM_ (\is (sh,pic) -> pokeLayVerxs vbos counts pic >> pokeShape' ptr iptr ieptr is sh)
-- (return (0,0,0)) return
pokeShape :: Ptr Float -> Ptr GLushort -> Ptr GLushort pokeShape :: Ptr Float -> Ptr GLushort -> Ptr GLushort
-> VFSM.Stream IO ShapeObj
-> IO (Int,Int,Int)
pokeShape ptr iptr ieptr = VFSM.foldlM' (pokeShapeObj ptr iptr ieptr) (0,0,0)
--pokeShape' :: Ptr Float -> Ptr GLushort -> Ptr GLushort
-- -> (Int,Int,Int)
-- -> Stream (Of ShapeObj) IO ()
-- -> IO (Int,Int,Int)
--pokeShape' ptr iptr ieptr is = S.foldM_ (pokeShapeObj ptr iptr ieptr) (return is) return
--
pokeShape' :: Ptr Float -> Ptr GLushort -> Ptr GLushort
-> (Int,Int,Int) -> (Int,Int,Int)
-> [ShapeObj] -> [ShapeObj]
-> IO (Int,Int,Int) -> IO (Int,Int,Int)
pokeShape' ptr iptr ieptr is = VFSM.foldlM' (pokeShapeObj ptr iptr ieptr) is . VFSM.fromList pokeShape ptr iptr ieptr is = VFSM.foldlM' (pokeShapeObj ptr iptr ieptr) is . VFSM.fromList
pokeShapeObj pokeShapeObj
:: Ptr Float :: Ptr Float
@@ -260,18 +232,3 @@ poke34 ptr (V3 a b c) (V4 d e f g) = do
pokeArrayOff :: Ptr Float -> Int -> [Float] -> IO () pokeArrayOff :: Ptr Float -> Int -> [Float] -> IO ()
{-# INLINE pokeArrayOff #-} {-# INLINE pokeArrayOff #-}
pokeArrayOff ptr i = pokeArray (plusPtr ptr (floatSize * i)) pokeArrayOff ptr i = pokeArray (plusPtr ptr (floatSize * i))
--pokePoint33s :: Ptr Float -> [(Point3,Point3)] -> IO Int
--pokePoint33s ptr = S.foldM_ (pokePoint33 ptr) (return 0) return . S.each
--pokePoint33 :: Ptr Float -> Int -> (Point3,Point3) -> IO Int
--pokePoint33 ptr n (V3 a b c,V3 d e f) = do
-- pokeElemOff ptr (off 0) a
-- pokeElemOff ptr (off 1) b
-- pokeElemOff ptr (off 2) c
-- pokeElemOff ptr (off 3) d
-- pokeElemOff ptr (off 4) e
-- pokeElemOff ptr (off 5) f
-- return (n+1)
-- where
-- off i = n*6 + i