Tweak rewind gun

This commit is contained in:
2022-12-30 11:43:29 +00:00
parent 5bc764655d
commit 29d6307076
9 changed files with 24 additions and 15 deletions
+4 -4
View File
@@ -65,8 +65,8 @@ itNeedsLoading it = _laLoaded ic == 0 || not (_laPrimed ic)
activateEquipmentAt :: RightButtonOptions -> Creature -> World -> World activateEquipmentAt :: RightButtonOptions -> Creature -> World -> World
activateEquipmentAt rbo cr = activateEquipmentAt rbo cr =
cWorld . lWorld . 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 i, _) -> crLeftInvSel . lisMPos ?~ i
(_, Just _) -> crLeftInvSel .~ Nothing (_, Just _) -> crLeftInvSel . lisMPos .~ Nothing
_ -> id _ -> id
toggleEquipmentAt :: RightButtonOptions -> Int -> Creature -> World -> World toggleEquipmentAt :: RightButtonOptions -> Int -> Creature -> World -> World
@@ -114,7 +114,7 @@ useLeftItem cid w
| itmIsConsumable = 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 | itmIsEquipable = useItem cr w -- I believe this ONLY sets equipment options
| otherwise = fromMaybe w $ do | otherwise = fromMaybe w $ do
invid <- _crLeftInvSel cr invid <- cr ^. crLeftInvSel . lisMPos
itm <- cr ^? crInv . ix invid itm <- cr ^? crInv . ix invid
f <- cr ^? crInv . ix invid . itUse . leftUse f <- cr ^? crInv . ix invid . itUse . leftUse
return return
@@ -127,6 +127,6 @@ useLeftItem cid w
isJust (cr ^? crInv . ix (crSel cr) . itUse . cUse) isJust (cr ^? crInv . ix (crSel cr) . itUse . cUse)
itmIsEquipable = itmIsEquipable =
isJust (cr ^? crInv . ix (crSel cr) . itUse . equipEffect . eeUse) isJust (cr ^? crInv . ix (crSel cr) . itUse . equipEffect . eeUse)
&& _crLeftInvSel cr /= Just (crSel cr) && cr ^. crLeftInvSel . lisMPos /= Just (crSel cr)
-- TODO determine itmShouldBeUsed with reference to config options -- TODO determine itmShouldBeUsed with reference to config options
+1 -1
View File
@@ -53,7 +53,7 @@ data Creature = Creature
, _crInvLock :: Bool , _crInvLock :: Bool
, _crInvEquipped :: IM.IntMap EquipPosition , _crInvEquipped :: IM.IntMap EquipPosition
, _crEquipment :: M.Map EquipPosition Int , _crEquipment :: M.Map EquipPosition Int
, _crLeftInvSel :: Maybe Int , _crLeftInvSel :: LeftInvSel
, _crState :: CreatureState , _crState :: CreatureState
, _crCorpse :: CreatureCorpse --Creature -> Corpse -> SPic , _crCorpse :: CreatureCorpse --Creature -> Corpse -> SPic
, _crMaterial :: Material , _crMaterial :: Material
@@ -26,9 +26,16 @@ data InvSelAction
| ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction, _actionHammer :: HammerType} | ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction, _actionHammer :: HammerType}
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
data LeftInvSel = LeftInvSel
{ _lisMPos :: Maybe Int
, _lisActive :: Bool
}
makeLenses ''LoadAction makeLenses ''LoadAction
makeLenses ''InvSel makeLenses ''InvSel
makeLenses ''LeftInvSel
makeLenses ''InvSelAction makeLenses ''InvSelAction
deriveJSON defaultOptions ''LoadAction deriveJSON defaultOptions ''LoadAction
deriveJSON defaultOptions ''InvSelAction deriveJSON defaultOptions ''InvSelAction
deriveJSON defaultOptions ''InvSel deriveJSON defaultOptions ''InvSel
deriveJSON defaultOptions ''LeftInvSel
+1 -1
View File
@@ -29,7 +29,7 @@ defaultCreature =
, _crInvCapacity = 25 , _crInvCapacity = 25
, _crInvLock = False , _crInvLock = False
, _crInvEquipped = mempty , _crInvEquipped = mempty
, _crLeftInvSel = Nothing , _crLeftInvSel = LeftInvSel Nothing False
, _crState = defaultState , _crState = defaultState
, _crCorpse = MakeDefaultCorpse , _crCorpse = MakeDefaultCorpse
, _crMaterial = Flesh , _crMaterial = Flesh
+4 -4
View File
@@ -58,7 +58,7 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
& pointcid . crInv %~ f & pointcid . crInv %~ f
& pointcid . crInvSel %~ stopCrInvSelAction & pointcid . crInvSel %~ stopCrInvSelAction
& pointcid . crInvSel . iselPos %~ g & pointcid . crInvSel . iselPos %~ g
& pointcid . crLeftInvSel %~ g' & pointcid . crLeftInvSel . lisMPos %~ g'
& removeAnySlotEquipment & removeAnySlotEquipment
& dounequipfunction & dounequipfunction
& doanyitemeffect & doanyitemeffect
@@ -260,7 +260,7 @@ setEquipActivation :: World -> World
setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of
Just DoNotMoveEquipment -> w Just DoNotMoveEquipment -> w
Just RemoveEquipment{} -> Just RemoveEquipment{} ->
case _crLeftInvSel (you w) of case you w ^. crLeftInvSel . lisMPos of
Just i Just i
| i == invsel -> | i == invsel ->
w & rbOptions . opActivateEquipment w & rbOptions . opActivateEquipment
@@ -269,7 +269,7 @@ setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of
} }
_ -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment _ -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
Just rbos -> Just rbos ->
case _crLeftInvSel (you w) of case you w ^. crLeftInvSel . lisMPos of
Just i | i == invsel -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment Just i | i == invsel -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
Just i Just i
| invselcanactivate -> | invselcanactivate ->
@@ -339,7 +339,7 @@ changeSwapInvSel k w
where where
updatecreature = updatecreature =
(crInv %~ IM.safeSwapKeys (i `mod` n) swapi) (crInv %~ IM.safeSwapKeys (i `mod` n) swapi)
. (crLeftInvSel . _Just %~ updateLeftInvSel) . (crLeftInvSel . lisMPos . _Just %~ updateLeftInvSel)
. (crInvSel . iselPos %~ (`mod` n) . subtract k) . (crInvSel . iselPos %~ (`mod` n) . subtract k)
. (crInvEquipped %~ IM.safeSwapKeys i swapi) . (crInvEquipped %~ IM.safeSwapKeys i swapi)
. swapSite i swapi . swapSite i swapi
+1 -1
View File
@@ -42,7 +42,7 @@ chargeIfInInventory itm cr w =
chargeIfEquipped :: Item -> Creature -> World -> World chargeIfEquipped :: Item -> Creature -> World -> World
chargeIfEquipped itm cr w chargeIfEquipped itm cr w
| Just invid == _crLeftInvSel cr = | Just invid == cr ^. crLeftInvSel . lisMPos =
w & ptrWpCharge %~ (min maxcharge . (+ 1)) w & ptrWpCharge %~ (min maxcharge . (+ 1))
| otherwise = | otherwise =
w & ptrWpCharge .~ 0 w & ptrWpCharge .~ 0
+1 -1
View File
@@ -121,7 +121,7 @@ drawNoSubInventory cfig w =
cfig cfig
(Just i) (Just i)
(inventorySelectionList w) (inventorySelectionList w)
equipcursor = case _crLeftInvSel cr of equipcursor = case cr ^. crLeftInvSel . lisMPos of
Just invid -> f cyan invid (_crInvEquipped cr IM.! invid) Just invid -> f cyan invid (_crInvEquipped cr IM.! invid)
_ -> mempty _ -> mempty
equipcursors = IM.foldMapWithKey (f yellow) (_crInvEquipped cr) equipcursors = IM.foldMapWithKey (f yellow) (_crInvEquipped cr)
+3 -2
View File
@@ -196,8 +196,8 @@ functionalUpdate' :: Universe -> Universe
functionalUpdate' u = case u ^. uvWorld . cWorld . timeFlow of functionalUpdate' u = case u ^. uvWorld . cWorld . timeFlow of
NormalTimeFlow -> functionalUpdate u NormalTimeFlow -> functionalUpdate u
ScrollTimeFlow smoothing _ _ _ -> over uvWorld (doTimeScroll smoothing) u ScrollTimeFlow smoothing _ _ _ -> over uvWorld (doTimeScroll smoothing) u
RewindLeftClick 0 _ -> u RewindLeftClick 0 _ -> u & uvWorld . cWorld . timeFlow .~ NormalTimeFlow
RewindLeftClick _ _ -> over uvWorld scrollTimeBack u & uvWorld . cWorld . timeFlow .~ NormalTimeFlow RewindLeftClick _ _ -> over uvWorld scrollTimeBack u -- & uvWorld . cWorld . timeFlow .~ NormalTimeFlow
_ -> u _ -> u
doTimeScroll :: Int -> World -> World doTimeScroll :: Int -> World -> World
@@ -226,6 +226,7 @@ scrollTimeBack w = case w ^? cWorld . pastWorlds . _head of
& cWorld . timeFlow . reverseAmount -~ 1 & cWorld . timeFlow . reverseAmount -~ 1
& cWorld . lWorld .~ lw & cWorld . lWorld .~ lw
& pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ (x -1) & pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ (x -1)
& pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftHammer .~ HammerDown
_ -> w _ -> w
where where
i = w ^?! cWorld . timeFlow . scrollItemLocation i = w ^?! cWorld . timeFlow . scrollItemLocation
+2 -1
View File
@@ -53,7 +53,8 @@ pressedMBEffectsNoInventory :: M.Map MouseButton Bool -> World -> World
pressedMBEffectsNoInventory pkeys w pressedMBEffectsNoInventory pkeys w
| isDown ButtonLeft && isDown ButtonRight && inTopInv = | isDown ButtonLeft && isDown ButtonRight && inTopInv =
useItem (you w) w & input . hammers . ix DoubleMouseHam .~ HammerDown useItem (you w) w & input . hammers . ix DoubleMouseHam .~ HammerDown
| justPressedDown ButtonLeft && inTopInv | isDown ButtonLeft && inTopInv
-- | justPressedDown ButtonLeft && inTopInv
&& w ^?! input . hammers . ix DoubleMouseHam == HammerUp = && w ^?! input . hammers . ix DoubleMouseHam == HammerUp =
useLeftItem 0 w useLeftItem 0 w
| isDown ButtonLeft && inTopInv = | isDown ButtonLeft && inTopInv =