Commit before moving button press events from events into your control

This commit is contained in:
2022-06-29 12:12:45 +01:00
parent 5501d6f9b5
commit 4b8155ae16
8 changed files with 55 additions and 28 deletions
+3
View File
@@ -236,6 +236,9 @@ inventoryX c = case c of
, makeTypeCraftNum 5 STATICMODULE , makeTypeCraftNum 5 STATICMODULE
] ]
'H' -> [ shatterGun ] 'H' -> [ shatterGun ]
'I' -> [ makeTypeCraft TELEPORTMODULE
, makeTypeCraftNum 2 MICROCHIP
]
_ -> [] _ -> []
testInventory :: IM.IntMap Item testInventory :: IM.IntMap Item
+5 -1
View File
@@ -165,7 +165,7 @@ data World = World
, _rewindWorlds :: [World] , _rewindWorlds :: [World]
, _timeFlow :: TimeFlowStatus , _timeFlow :: TimeFlowStatus
, _worldClock :: Int , _worldClock :: Int
, _doubleMouseHammer :: HammerPosition , _hammers :: M.Map WorldHammer HammerPosition
, _backspaceTimer :: Int , _backspaceTimer :: Int
, _genParams :: GenParams , _genParams :: GenParams
, _genPlacements :: IM.IntMap [(Placement,Int)] , _genPlacements :: IM.IntMap [(Placement,Int)]
@@ -174,6 +174,10 @@ data World = World
, _testFloat :: Float , _testFloat :: Float
, _wSelect :: (Point2,Point2) , _wSelect :: (Point2,Point2)
} }
data WorldHammer
= SubInvHam
| DoubleMouseHam
deriving (Eq,Ord,Show,Enum,Bounded)
newtype GenParams = GenParams newtype GenParams = GenParams
{ _sensorCoding :: M.Map DamageType (PaletteColor,DecorationShape) { _sensorCoding :: M.Map DamageType (PaletteColor,DecorationShape)
+1
View File
@@ -10,6 +10,7 @@ data Zoning t a = Zoning
{ _znObjects :: IM.IntMap (IM.IntMap (t a)) { _znObjects :: IM.IntMap (IM.IntMap (t a))
, _znSize :: Float , _znSize :: Float
, _znFunc :: Float -> a -> StreamOf Int2 , _znFunc :: Float -> a -> StreamOf Int2
-- , _znInsert :: a -> t a -> t a
} }
makeLenses ''Zoning makeLenses ''Zoning
+3 -1
View File
@@ -102,7 +102,7 @@ defaultWorld = World
, _maybeWorld = Nothing' , _maybeWorld = Nothing'
, _rewindWorlds = [] , _rewindWorlds = []
, _timeFlow = NormalTimeFlow , _timeFlow = NormalTimeFlow
, _doubleMouseHammer = HammerUp , _hammers = defaultWorldHammers
, _backspaceTimer = 0 , _backspaceTimer = 0
, _genParams = GenParams M.empty , _genParams = GenParams M.empty
, _genPlacements = IM.empty , _genPlacements = IM.empty
@@ -113,6 +113,8 @@ defaultWorld = World
, _boundDist = (100,-100,100,-100) , _boundDist = (100,-100,100,-100)
, _wSelect = (0,0) , _wSelect = (0,0)
} }
defaultWorldHammers :: M.Map WorldHammer HammerPosition
defaultWorldHammers = M.fromSet (const HammerUp) $ S.fromList [minBound.. maxBound]
youLight :: TempLightSource youLight :: TempLightSource
youLight = TLS youLight = TLS
{ _tlsParam = LSParam { _tlsParam = LSParam
+7 -7
View File
@@ -45,13 +45,13 @@ initialAnoTree = OnwardList
, AnRoom slowDoorRoom , AnRoom slowDoorRoom
-- , AnRoom $ roomCCrits 10 -- , AnRoom $ roomCCrits 10
, AnTree firstBreather , AnTree firstBreather
, AnTree $ telRoomLev 1 >>= rToOnward "telRoomLev" . pure . cleatOnward -- , AnTree $ telRoomLev 1 >>= rToOnward "telRoomLev" . pure . cleatOnward
] -- ]
--
extraAnoList :: [Annotation] --extraAnoList :: [Annotation]
extraAnoList = --extraAnoList =
-- , (SpecificRoom . return . tToBTree $ treePost [corridor,corridor,cleatOnward corridor]) ---- , (SpecificRoom . return . tToBTree $ treePost [corridor,corridor,cleatOnward corridor])
[ AnRoom $ roomCCrits 10 -- [ AnRoom $ roomCCrits 10
, AnRoom $ roomCCrits 10 , AnRoom $ roomCCrits 10
, AnTree $ tToBTree "spawners" <$> spawnerRoom , AnTree $ tToBTree "spawners" <$> spawnerRoom
, AnRoom pistolerRoom , AnRoom pistolerRoom
+1 -2
View File
@@ -3,6 +3,5 @@ import Dodge.Item.Data
moveHammerUp :: HammerPosition -> HammerPosition moveHammerUp :: HammerPosition -> HammerPosition
moveHammerUp HammerDown = HammerReleased moveHammerUp HammerDown = HammerReleased
moveHammerUp HammerReleased = HammerUp moveHammerUp _ = HammerUp
moveHammerUp HammerUp = HammerUp
+17 -13
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE BangPatterns #-}
{- | {- |
Module : Dodge.Update Module : Dodge.Update
Description : Simulation update Description : Simulation update
@@ -60,7 +61,7 @@ functionalUpdate cfig w = checkEndGame
. (worldClock +~ 1) . (worldClock +~ 1)
. updateWorldSelect . updateWorldSelect
. doRewind . doRewind
. (doubleMouseHammer %~ moveHammerUp) . (hammers . each %~ moveHammerUp)
. updateDistortions . updateDistortions
. updateCreatureSoundPositions . updateCreatureSoundPositions
. ppEvents . ppEvents
@@ -146,9 +147,11 @@ doRewind w = case _maybeWorld w of
Nothing' -> w & timeFlow .~ NormalTimeFlow Nothing' -> w & timeFlow .~ NormalTimeFlow
zoneCreatures :: World -> World zoneCreatures :: World -> World
zoneCreatures w = w & crZoning %~ \zn -> zoneCreatures w = w
foldl' (flip $ updateZoning (\cr -> IM.insert (_crID cr) cr)) & crZoning . znObjects .~ mempty
(zn & znObjects .~ mempty) (_creatures w) & crZoning %~ \zn ->
foldl' (flip $ updateZoning (\cr -> IM.insert (_crID cr) cr))
zn (_creatures w)
updateCreatureSoundPositions :: World -> World updateCreatureSoundPositions :: World -> World
updateCreatureSoundPositions w = M.foldlWithKey' insertSound w updateCreatureSoundPositions w = M.foldlWithKey' insertSound w
@@ -286,16 +289,17 @@ ppEvents :: World -> World
ppEvents w = IM.foldl' (flip $ \pp -> _ppEvent pp pp) w $ _pressPlates w ppEvents w = IM.foldl' (flip $ \pp -> _ppEvent pp pp) w $ _pressPlates w
updateSeenWalls :: World -> World updateSeenWalls :: World -> World
updateSeenWalls w = runIdentity $ S.fold_ f w id (S.map (_wlID . snd) $ allVisibleWalls w) updateSeenWalls w = runIdentity $ S.fold_ markWallSeen w id (S.map (_wlID . snd) $ allVisibleWalls w)
where
f w' i -- = w' & walls . ix i . wlSeen .~ True -- this is much simpler, but leaks
= w' { _walls = IM.adjust mw i $ _walls w' }
mw wl = wl {_wlSeen = True}
--markWallSeen :: World -> Wall -> World
--markWallSeen w wl = w { _walls = IM.adjust mw (_wlID wl) $ _walls w }
-- where -- where
-- mw wl' = wl' {_wlSeen = True} -- f w' !i -- = w' & walls . ix i . wlSeen .~ True
-- = w' { _walls = IM.adjust mw i $ _walls w' }
-- mw wl = wl {_wlSeen = True}
markWallSeen :: World -> Int -> World
markWallSeen !w !i = w { _walls = IM.adjust markSeen i $ _walls w }
markSeen :: Wall -> Wall
markSeen wl = wl {_wlSeen = True}
checkEndGame :: World -> World checkEndGame :: World -> World
checkEndGame w = case _deathDelay w of checkEndGame w = case _deathDelay w of
+17 -3
View File
@@ -17,19 +17,33 @@ updateUsingInput w = case _hudElement $ _hud w of
DisplayInventory {} -> updatePressedButtons (_mouseButtons w) w DisplayInventory {} -> updatePressedButtons (_mouseButtons w) w
DisplayCarte -> updatePressedButtonsCarte (_mouseButtons w) w DisplayCarte -> updatePressedButtonsCarte (_mouseButtons w) w
-- ugly check for subinventory inventory hammer, this should change
updatePressedButtons :: M.Map MouseButton Bool -> World -> World updatePressedButtons :: M.Map MouseButton Bool -> World -> World
updatePressedButtons pkeys w updatePressedButtons pkeys w
| ButtonLeft `M.member` pkeys &&
(inSubInv || w ^?! hammers . ix SubInvHam /= HammerUp)
= undefined --w & hammers . ix SubInvHam .~ HammerDown
| otherwise = updatePressedButtons' pkeys w
where
inSubInv = case _hudElement (_hud w) of
DisplayInventory NoSubInventory -> False
DisplayInventory _ -> True
_ -> False
updatePressedButtons' :: M.Map MouseButton Bool -> World -> World
updatePressedButtons' pkeys w
| isDown ButtonLeft && isDown ButtonRight && inTopInv | isDown ButtonLeft && isDown ButtonRight && inTopInv
= useItem (you w) w & doubleMouseHammer .~ HammerDown = useItem (you w) w & hammers . ix DoubleMouseHam .~ HammerDown
| isDown ButtonLeft && (inTopInv || _timeFlow w == RewindingLastFrame) | isDown ButtonLeft && (inTopInv || _timeFlow w == RewindingLastFrame)
&& _doubleMouseHammer w == HammerUp && w ^?! hammers . ix DoubleMouseHam == HammerUp
= useLeftItem (_yourID w) w = useLeftItem (_yourID w) w
| isDown ButtonLeft && (inTopInv || _timeFlow w == RewindingLastFrame) | isDown ButtonLeft && (inTopInv || _timeFlow w == RewindingLastFrame)
= w & doubleMouseHammer .~ HammerDown = w & hammers . ix DoubleMouseHam .~ HammerDown
| isDown ButtonRight && inTopInv = w | isDown ButtonRight && inTopInv = w
| isDown ButtonMiddle | isDown ButtonMiddle
= w & cameraRot -~ rotation = w & cameraRot -~ rotation
& clickMousePos .~ _mousePos w & clickMousePos .~ _mousePos w
| isDown ButtonLeft = w & hammers . ix DoubleMouseHam .~ HammerDown
| otherwise = w | otherwise = w
where where
inTopInv = case _hudElement (_hud w) of inTopInv = case _hudElement (_hud w) of