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