Continue inventory tweak
This commit is contained in:
@@ -12,7 +12,7 @@ youc w = w ^?! lWorld . creatures . ix 0
|
|||||||
|
|
||||||
yourItem :: World -> Maybe Item
|
yourItem :: World -> Maybe Item
|
||||||
yourItem w = do
|
yourItem w = do
|
||||||
i <- you w ^? crManipulation . isel . ispItem
|
i <- you w ^? crManipulation . manObject . inInventory . ispItem
|
||||||
_crInv (you w) IM.!? i
|
_crInv (you w) IM.!? i
|
||||||
|
|
||||||
yourInv :: World -> IM.IntMap Item
|
yourInv :: World -> IM.IntMap Item
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ dropItem cr invid = rmInvItem cid invid . copyInvItemToFloor cr invid -- . maybe
|
|||||||
-- | Get your creature to drop the item under the cursor.
|
-- | Get your creature to drop the item under the cursor.
|
||||||
youDropItem :: World -> World
|
youDropItem :: World -> World
|
||||||
youDropItem w = fromMaybe w $ do
|
youDropItem w = fromMaybe w $ do
|
||||||
curpos <- you w ^? crManipulation . isel . ispItem
|
curpos <- you w ^? crManipulation . manObject . inInventory . ispItem
|
||||||
guard $ not $ _crInvLock (you w) || cursed
|
guard $ not $ _crInvLock (you w) || cursed
|
||||||
return $ w
|
return $ w
|
||||||
& dropItem cr curpos
|
& dropItem cr curpos
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ followImpulse cr w imp = case imp of
|
|||||||
TurnTo p -> crup $ creatureTurnTo p cr
|
TurnTo p -> crup $ creatureTurnTo p cr
|
||||||
ChangePosture post -> crup $ cr & crStance . posture .~ post
|
ChangePosture post -> crup $ cr & crStance . posture .~ post
|
||||||
UseItem -> (useItem cr, cr)
|
UseItem -> (useItem cr, cr)
|
||||||
SwitchToItem i -> crup $ cr & crManipulation .~ Manipulator (SelItem i NoInvSelAction)
|
SwitchToItem i -> crup $ cr & crManipulation . manObject .~ InInventory (SelItem i NoInvSelAction)
|
||||||
Melee cid' ->
|
Melee cid' ->
|
||||||
( hitCr cid'
|
( hitCr cid'
|
||||||
, crMvBy (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crMeleeCooldown .~ 20
|
, crMvBy (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crMeleeCooldown .~ 20
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import qualified SDL
|
|||||||
useItem :: Creature -> World -> World
|
useItem :: Creature -> World -> World
|
||||||
useItem cr' w = fromMaybe (f w) $ do
|
useItem cr' w = fromMaybe (f w) $ do
|
||||||
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
cr <- w ^? cWorld . lWorld . creatures . ix (_crID cr')
|
||||||
itRef <- cr ^? crManipulation . isel . ispItem
|
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
it <- cr ^? crInv . ix itRef
|
it <- cr ^? crInv . ix itRef
|
||||||
return $ itemEffect cr it w
|
return $ itemEffect cr it w
|
||||||
where
|
where
|
||||||
@@ -39,7 +39,7 @@ itemEffect cr it w = case it ^. itUse of
|
|||||||
(ConsumeUse eff _) -> setuhamdown $ hammerTest $ useC eff it cr . rmInvItem (_crID cr) itRef
|
(ConsumeUse eff _) -> setuhamdown $ hammerTest $ useC eff it cr . rmInvItem (_crID cr) itRef
|
||||||
CraftUse{} -> setuhamdown w
|
CraftUse{} -> setuhamdown w
|
||||||
where
|
where
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
hammerTest f = case _crHammerPosition cr of
|
hammerTest f = case _crHammerPosition cr of
|
||||||
HammerUp -> f w
|
HammerUp -> f w
|
||||||
_ -> w & setuhamdown
|
_ -> w & setuhamdown
|
||||||
@@ -109,7 +109,7 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
|
|||||||
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
||||||
itmat i = _crInv cr IM.! i
|
itmat i = _crInv cr IM.! i
|
||||||
itm = itmat itRef
|
itm = itmat itRef
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
onequip itm' = useE ((_eeOnEquip . _equipEffect . _itUse) itm') itm'
|
onequip itm' = useE ((_eeOnEquip . _equipEffect . _itUse) itm') itm'
|
||||||
onremove itm' = useE ((_eeOnRemove . _equipEffect . _itUse) itm') itm'
|
onremove itm' = useE ((_eeOnRemove . _equipEffect . _itUse) itm') itm'
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ useLeftItem :: Int -> World -> World
|
|||||||
useLeftItem cid w = fromMaybe w $ do
|
useLeftItem cid w = fromMaybe w $ do
|
||||||
cr <- w ^? cWorld . lWorld . creatures . ix cid
|
cr <- w ^? cWorld . lWorld . creatures . ix cid
|
||||||
guard . not $ _crInvLock cr
|
guard . not $ _crInvLock cr
|
||||||
let mitRef = cr ^? crManipulation . isel . ispItem
|
let mitRef = cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
itmIsConsumable = isJust $ do
|
itmIsConsumable = isJust $ do
|
||||||
itRef <- mitRef
|
itRef <- mitRef
|
||||||
cr ^? crInv . ix itRef . itUse . cUse
|
cr ^? crInv . ix itRef . itUse . cUse
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ doStrategyActions cr = case cr ^? crActionPlan . apStrategy of
|
|||||||
reloadOverride :: Creature -> Creature
|
reloadOverride :: Creature -> Creature
|
||||||
reloadOverride cr = fromMaybe cr $ do
|
reloadOverride cr = fromMaybe cr $ do
|
||||||
guard $ cr ^. crStance . posture == Aiming
|
guard $ cr ^. crStance . posture == Aiming
|
||||||
itRef <- cr ^? crManipulation . isel . ispItem
|
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
guard $ cr ^? crInv . ix itRef . itUse . heldConsumption . laLoaded == Just 0
|
guard $ cr ^? crInv . ix itRef . itUse . heldConsumption . laLoaded == Just 0
|
||||||
return $ cr & crActionPlan . apStrategy .~ StrategyActions Reload reloadActions
|
return $ cr & crActionPlan . apStrategy .~ StrategyActions Reload reloadActions
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ stateUpdate f =
|
|||||||
heldAimEffects :: Creature -> World -> World
|
heldAimEffects :: Creature -> World -> World
|
||||||
heldAimEffects cr = fromMaybe id $ do
|
heldAimEffects cr = fromMaybe id $ do
|
||||||
guard (crIsAiming cr)
|
guard (crIsAiming cr)
|
||||||
ipos <- cr ^? crManipulation . isel . ispItem
|
ipos <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
itm <- cr ^? crInv . ix ipos
|
itm <- cr ^? crInv . ix ipos
|
||||||
f <- itm ^? itEffect . ieWhileAiming
|
f <- itm ^? itEffect . ieWhileAiming
|
||||||
return $ doInvEffect f itm cr
|
return $ doInvEffect f itm cr
|
||||||
@@ -263,7 +263,7 @@ itemUpdate cr i = updateAutoRecharge
|
|||||||
. (itLocation .~ InInv (_crID cr) i)
|
. (itLocation .~ InInv (_crID cr) i)
|
||||||
. (itIsHeld .~ itmisheld)
|
. (itIsHeld .~ itmisheld)
|
||||||
where
|
where
|
||||||
itmisheld = Just i == (cr ^? crManipulation . isel . ispItem)
|
itmisheld = Just i == (cr ^? crManipulation . manObject . inInventory . ispItem)
|
||||||
|
|
||||||
updateAutoRecharge :: Item -> Item
|
updateAutoRecharge :: Item -> Item
|
||||||
updateAutoRecharge it = case it ^? itUse . leftConsumption of
|
updateAutoRecharge it = case it ^? itUse . leftConsumption of
|
||||||
@@ -279,12 +279,12 @@ crGetTargeting cr = do
|
|||||||
where
|
where
|
||||||
hastargeting itm = isJust (itm ^? itUse . useTargeting . _Just)
|
hastargeting itm = isJust (itm ^? itUse . useTargeting . _Just)
|
||||||
helditem = fromMaybe [] $ do
|
helditem = fromMaybe [] $ do
|
||||||
i <- cr ^? crManipulation . isel . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
itm <- cr ^? crInv . ix i
|
itm <- cr ^? crInv . ix i
|
||||||
return [itm]
|
return [itm]
|
||||||
|
|
||||||
weaponReloadSounds :: Creature -> World -> World
|
weaponReloadSounds :: Creature -> World -> World
|
||||||
weaponReloadSounds cr w = case cr ^? crManipulation . isel . iselAction of
|
weaponReloadSounds cr w = case cr ^? crManipulation . manObject . inInventory . iselAction of
|
||||||
Just ReloadAction{_reloadAction = la} ->
|
Just ReloadAction{_reloadAction = la} ->
|
||||||
soundContinue
|
soundContinue
|
||||||
(CrReloadSound cid)
|
(CrReloadSound cid)
|
||||||
|
|||||||
@@ -37,6 +37,6 @@ crCurrentEquipment cr =
|
|||||||
strFromHeldItem :: Creature -> Int
|
strFromHeldItem :: Creature -> Int
|
||||||
strFromHeldItem cr
|
strFromHeldItem cr
|
||||||
| _posture (_crStance cr) == Aiming || crIsReloading cr = negate $ fromMaybe 0 $ do
|
| _posture (_crStance cr) == Aiming || crIsReloading cr = negate $ fromMaybe 0 $ do
|
||||||
i <- cr ^? crManipulation . isel . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
cr ^? crInv . ix i . itUse . heldAim . aimWeight
|
cr ^? crInv . ix i . itUse . heldAim . aimWeight
|
||||||
| otherwise = 0
|
| otherwise = 0
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ import Dodge.Data.World
|
|||||||
import Geometry
|
import Geometry
|
||||||
|
|
||||||
crIsReloading :: Creature -> Bool
|
crIsReloading :: Creature -> Bool
|
||||||
crIsReloading cr = case cr ^? crManipulation . isel . iselAction of
|
crIsReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
|
||||||
Just ReloadAction{} -> True
|
Just ReloadAction{} -> True
|
||||||
_ -> False
|
_ -> False
|
||||||
|
|
||||||
crWeaponReady :: Creature -> Bool
|
crWeaponReady :: Creature -> Bool
|
||||||
crWeaponReady cr = fromMaybe False $ do
|
crWeaponReady cr = fromMaybe False $ do
|
||||||
i <- cr ^? crManipulation . isel . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
ic <- cr ^? crInv . ix i . itUse . heldConsumption
|
ic <- cr ^? crInv . ix i . itUse . heldConsumption
|
||||||
return (_laLoaded ic > 0 && _laPrimed ic)
|
return (_laLoaded ic > 0 && _laPrimed ic)
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ crInAimStance as cr =
|
|||||||
&& mitstance == Just as
|
&& mitstance == Just as
|
||||||
where
|
where
|
||||||
mitstance = do
|
mitstance = do
|
||||||
i <- cr ^? crManipulation . isel . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
cr ^? crInv . ix i . itUse . heldAim . aimStance
|
cr ^? crInv . ix i . itUse . heldAim . aimStance
|
||||||
|
|
||||||
oneH :: Creature -> Bool
|
oneH :: Creature -> Bool
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ wasdWithAiming w speed cr
|
|||||||
& crDir +~ _crTwist cr'
|
& crDir +~ _crTwist cr'
|
||||||
& crTwist .~ 0
|
& crTwist .~ 0
|
||||||
addAnyTwist = fromMaybe id $ do
|
addAnyTwist = fromMaybe id $ do
|
||||||
itRef <- cr ^? crManipulation . isel . ispItem
|
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance
|
astance <- cr ^? crInv . ix itRef . itUse . heldAim . aimStance
|
||||||
let currenttwistamount = cr ^. crTwist
|
let currenttwistamount = cr ^. crTwist
|
||||||
case (astance,currenttwistamount) of
|
case (astance,currenttwistamount) of
|
||||||
@@ -73,7 +73,7 @@ wasdWithAiming w speed cr
|
|||||||
mouseDir = fromMaybe
|
mouseDir = fromMaybe
|
||||||
(argV (_mousePos (_input w)) + (w ^. cWorld . camPos . camRot) )
|
(argV (_mousePos (_input w)) + (w ^. cWorld . camPos . camRot) )
|
||||||
$ do
|
$ do
|
||||||
itRef <- cr ^? crManipulation . isel . ispItem
|
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
_ <- cr ^? crInv . ix itRef . itScope . scopePos
|
_ <- cr ^? crInv . ix itRef . itScope . scopePos
|
||||||
return . argV $ mouseWorldPos (w ^. input) (w ^. cWorld . camPos) -.- _crPos cr
|
return . argV $ mouseWorldPos (w ^. input) (w ^. cWorld . camPos) -.- _crPos cr
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ aimTurn :: Float -> Creature -> Creature
|
|||||||
aimTurn a cr = creatureTurnTowardDir a (x * 0.2) cr
|
aimTurn a cr = creatureTurnTowardDir a (x * 0.2) cr
|
||||||
where
|
where
|
||||||
x = fromMaybe 1 $ do
|
x = fromMaybe 1 $ do
|
||||||
itRef <- cr ^? crManipulation . isel . ispItem
|
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
cr ^? crInv . ix itRef . itUse . heldAim . aimTurnSpeed
|
cr ^? crInv . ix itRef . itUse . heldAim . aimTurnSpeed
|
||||||
|
|
||||||
wasdM :: SDL.Scancode -> Point2
|
wasdM :: SDL.Scancode -> Point2
|
||||||
@@ -104,5 +104,5 @@ mouseActionsCr pkeys cr
|
|||||||
where
|
where
|
||||||
rbPressed = SDL.ButtonRight `M.member` pkeys
|
rbPressed = SDL.ButtonRight `M.member` pkeys
|
||||||
noaction = fromMaybe True $ do
|
noaction = fromMaybe True $ do
|
||||||
theaction <- cr ^? crManipulation . isel . iselAction
|
theaction <- cr ^? crManipulation . manObject . inInventory . iselAction
|
||||||
return $ theaction == NoInvSelAction
|
return $ theaction == NoInvSelAction
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ data Intention = Intention
|
|||||||
--deriving (Eq, Show, Read) --Generic, Flat)
|
--deriving (Eq, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
crSel :: Creature -> ManipulatedObject
|
crSel :: Creature -> ManipulatedObject
|
||||||
crSel = _isel . _crManipulation
|
crSel = _manObject . _crManipulation
|
||||||
|
|
||||||
makeLenses ''Creature
|
makeLenses ''Creature
|
||||||
makeLenses ''CreatureTargeting
|
makeLenses ''CreatureTargeting
|
||||||
|
|||||||
@@ -19,17 +19,23 @@ data LoadAction
|
|||||||
|
|
||||||
data Manipulation -- should be ManipulatedObject?
|
data Manipulation -- should be ManipulatedObject?
|
||||||
-- = InvSel {_isel :: SelPos}
|
-- = InvSel {_isel :: SelPos}
|
||||||
= Manipulator {_isel :: ManipulatedObject}
|
= Manipulator {_manObject :: ManipulatedObject
|
||||||
|
, _invRegex :: Maybe String
|
||||||
|
}
|
||||||
| Brute
|
| Brute
|
||||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
data ManipulatedObject
|
data ManipulatedObject
|
||||||
= SelItem { _ispItem :: Int
|
= InInventory {_inInventory :: InventoryManipulation}
|
||||||
, _iselAction :: InvSelAction}
|
|
||||||
| SelNothing
|
| SelNothing
|
||||||
| SelCloseObject {_ispCloseObject :: Int}
|
| SelCloseObject {_ispCloseObject :: Int}
|
||||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
|
data InventoryManipulation
|
||||||
|
= SortInventory
|
||||||
|
| SelItem { _ispItem :: Int, _iselAction :: InvSelAction}
|
||||||
|
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
data InvSelAction
|
data InvSelAction
|
||||||
= NoInvSelAction
|
= NoInvSelAction
|
||||||
| ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction}
|
| ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction}
|
||||||
@@ -43,10 +49,12 @@ data LeftInvSel = LeftInvSel
|
|||||||
makeLenses ''LoadAction
|
makeLenses ''LoadAction
|
||||||
makeLenses ''ManipulatedObject
|
makeLenses ''ManipulatedObject
|
||||||
makeLenses ''Manipulation
|
makeLenses ''Manipulation
|
||||||
|
makeLenses ''InventoryManipulation
|
||||||
makeLenses ''LeftInvSel
|
makeLenses ''LeftInvSel
|
||||||
makeLenses ''InvSelAction
|
makeLenses ''InvSelAction
|
||||||
deriveJSON defaultOptions ''LoadAction
|
deriveJSON defaultOptions ''LoadAction
|
||||||
deriveJSON defaultOptions ''InvSelAction
|
deriveJSON defaultOptions ''InvSelAction
|
||||||
|
deriveJSON defaultOptions ''InventoryManipulation
|
||||||
deriveJSON defaultOptions ''ManipulatedObject
|
deriveJSON defaultOptions ''ManipulatedObject
|
||||||
deriveJSON defaultOptions ''Manipulation
|
deriveJSON defaultOptions ''Manipulation
|
||||||
deriveJSON defaultOptions ''LeftInvSel
|
deriveJSON defaultOptions ''LeftInvSel
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ data SelectionSection a = SelectionSection
|
|||||||
, _ssDescriptor :: String
|
, _ssDescriptor :: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
data Regex = UnavailableRegex
|
data Regex = UnavailableRegex
|
||||||
| EmptyRegex
|
| EmptyRegex
|
||||||
| Regex {_regexString :: String}
|
| Regex {_regexString :: String}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ defaultCreature =
|
|||||||
, _crHP = 100
|
, _crHP = 100
|
||||||
, _crMaxHP = 150
|
, _crMaxHP = 150
|
||||||
, _crInv = IM.empty
|
, _crInv = IM.empty
|
||||||
, _crManipulation = Manipulator SelNothing
|
, _crManipulation = Manipulator SelNothing Nothing
|
||||||
, _crInvCapacity = 25
|
, _crInvCapacity = 25
|
||||||
, _crInvLock = False
|
, _crInvLock = False
|
||||||
, _crInvEquipped = mempty
|
, _crInvEquipped = mempty
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ import Dodge.Data.SelectionList
|
|||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
|
|
||||||
updateDisplayInventory :: World -> Configuration -> SelectionSections () -> SelectionSections ()
|
updateDisplayInventory :: World -> Configuration -> SelectionSections () -> SelectionSections ()
|
||||||
updateDisplayInventory w cfig sss = case cr ^? crManipulation . isel of
|
updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of
|
||||||
Just (SelItem i _) -> sss
|
Just (InInventory SortInventory) -> sss
|
||||||
|
Just (InInventory (SelItem i _)) -> sss
|
||||||
{ _sssSections = updateSections availablelines (0,i) [invx ,youx, closex]
|
{ _sssSections = updateSections availablelines (0,i) [invx ,youx, closex]
|
||||||
, _sssSelPos = Just 0
|
, _sssSelPos = Just 0
|
||||||
}
|
}
|
||||||
@@ -36,6 +37,9 @@ updateDisplayInventory w cfig sss = case cr ^? crManipulation . isel of
|
|||||||
}
|
}
|
||||||
_ -> error "error when getting cr inv sel"
|
_ -> error "error when getting cr inv sel"
|
||||||
where
|
where
|
||||||
|
filtinv = (-1,(filtinvsec,filtinvitems))
|
||||||
|
filtinvsec = undefined
|
||||||
|
filtinvitems = undefined
|
||||||
invx = (0,(invsec, invitems))
|
invx = (0,(invsec, invitems))
|
||||||
youx = (1,(yousec, youitems))
|
youx = (1,(yousec, youitems))
|
||||||
closex = (2,(cosec, coitems))
|
closex = (2,(cosec, coitems))
|
||||||
|
|||||||
+2
-2
@@ -37,8 +37,8 @@ useE eo = case eo of
|
|||||||
trySiphonFuel :: Item -> Creature -> World -> World
|
trySiphonFuel :: Item -> Creature -> World -> World
|
||||||
trySiphonFuel itm cr w = fromMaybe w $ do
|
trySiphonFuel itm cr w = fromMaybe w $ do
|
||||||
eix <- itm ^? itLocation . ipInvID
|
eix <- itm ^? itLocation . ipInvID
|
||||||
hix <- cr ^? crManipulation . isel . ispItem
|
hix <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
guard (cr ^? crManipulation . isel . iselAction == Just NoInvSelAction)
|
guard (cr ^? crManipulation . manObject . inInventory . iselAction == Just NoInvSelAction)
|
||||||
la <- cr ^? crInv . ix hix . itUse . heldConsumption
|
la <- cr ^? crInv . ix hix . itUse . heldConsumption
|
||||||
atype <- la ^? laAmmoType
|
atype <- la ^? laAmmoType
|
||||||
guard (isGas atype)
|
guard (isGas atype)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ doHeldScroll hs = case hs of
|
|||||||
HeldScrollCharMode{} -> overYourItem $ \x _ -> itUse . heldScroll . hsCharMode %~ cycleSignum x
|
HeldScrollCharMode{} -> overYourItem $ \x _ -> itUse . heldScroll . hsCharMode %~ cycleSignum x
|
||||||
where
|
where
|
||||||
overYourItem f x cr w = fromMaybe w $ do
|
overYourItem f x cr w = fromMaybe w $ do
|
||||||
i <- cr ^? crManipulation . isel . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
return $ w & cWorld . lWorld . creatures . ix 0 . crInv . ix i %~ f x cr
|
return $ w & cWorld . lWorld . creatures . ix 0 . crInv . ix i %~ f x cr
|
||||||
|
|
||||||
cycleSignum :: Float -> Seq a -> Seq a
|
cycleSignum :: Float -> Seq a -> Seq a
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ overNozzles' ::
|
|||||||
overNozzles' eff it cr w = neww & cWorld . lWorld . creatures . ix cid . crInv . ix i . itParams . sprayNozzles .~ newNozzles
|
overNozzles' eff it cr w = neww & cWorld . lWorld . creatures . ix cid . crInv . ix i . itParams . sprayNozzles .~ newNozzles
|
||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
i = w ^?! cWorld . lWorld . creatures . ix cid . crManipulation . isel . ispItem
|
i = w ^?! cWorld . lWorld . creatures . ix cid . crManipulation . manObject . inInventory . ispItem
|
||||||
(neww, newNozzles) = mapAccumR (eff it cr) w $ _sprayNozzles (_itParams it)
|
(neww, newNozzles) = mapAccumR (eff it cr) w $ _sprayNozzles (_itParams it)
|
||||||
|
|
||||||
overNozzle ::
|
overNozzle ::
|
||||||
@@ -461,7 +461,7 @@ fireRemoteShell it cr w =
|
|||||||
, PJThrust 330 0
|
, PJThrust 330 0
|
||||||
, PJRemoteDirection 340 0 cid itid
|
, PJRemoteDirection 340 0 cid itid
|
||||||
]
|
]
|
||||||
j = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
j = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
|
|
||||||
caneStickSoundChoice :: Item -> SoundID
|
caneStickSoundChoice :: Item -> SoundID
|
||||||
caneStickSoundChoice it
|
caneStickSoundChoice it
|
||||||
@@ -502,7 +502,7 @@ shootTeslaArc it cr w =
|
|||||||
w'
|
w'
|
||||||
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itParams .~ ip
|
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itParams .~ ip
|
||||||
where
|
where
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
(w', ip) = makeTeslaArc (_itParams it) pos dir w
|
(w', ip) = makeTeslaArc (_itParams it) pos dir w
|
||||||
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
|
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
|
|||||||
+15
-15
@@ -60,7 +60,7 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
|
|||||||
& pointcid . crInv %~ f
|
& pointcid . crInv %~ f
|
||||||
& pointcid %~ crCancelReloading
|
& pointcid %~ crCancelReloading
|
||||||
-- & pointcid . crInvSel . iselPos %~ g THIS NEEDS CHECKING
|
-- & pointcid . crInvSel . iselPos %~ g THIS NEEDS CHECKING
|
||||||
& pointcid . crManipulation . isel . ispItem %~ g
|
& pointcid . crManipulation . manObject . inInventory . ispItem %~ g
|
||||||
& pointcid . crLeftInvSel . lisMPos %~ g'
|
& pointcid . crLeftInvSel . lisMPos %~ g'
|
||||||
& removeAnySlotEquipment
|
& removeAnySlotEquipment
|
||||||
& dounequipfunction
|
& dounequipfunction
|
||||||
@@ -98,7 +98,7 @@ rmInvItem cid invid w = case w ^? getcid . crInv . ix invid . itUse . useAmount
|
|||||||
| otherwise = Just x
|
| otherwise = Just x
|
||||||
|
|
||||||
rmSelectedInvItem :: Int -> World -> World
|
rmSelectedInvItem :: Int -> World -> World
|
||||||
rmSelectedInvItem cid w = case w ^? cWorld . lWorld . creatures . ix cid . crManipulation . isel . ispItem of
|
rmSelectedInvItem cid w = case w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . inInventory . ispItem of
|
||||||
Just i -> rmInvItem cid i w
|
Just i -> rmInvItem cid i w
|
||||||
Nothing -> w
|
Nothing -> w
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ updateCloseObjects w =
|
|||||||
where
|
where
|
||||||
newcloseobjects = unionBy closeObjEq oldCloseFiltered currentClose
|
newcloseobjects = unionBy closeObjEq oldCloseFiltered currentClose
|
||||||
updatecursorposifnecessary
|
updatecursorposifnecessary
|
||||||
= case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . isel . ispCloseObject of
|
= case w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject. ispCloseObject of
|
||||||
Just i | i >= length newcloseobjects -> changeAugInvSel 1
|
Just i | i >= length newcloseobjects -> changeAugInvSel 1
|
||||||
_ -> id
|
_ -> id
|
||||||
filt = filter $ \obj -> dist ypos (closeObjPos obj) < 40 && hasButtonLOS ypos (closeObjPos obj) w
|
filt = filter $ \obj -> dist ypos (closeObjPos obj) < 40 && hasButtonLOS ypos (closeObjPos obj) w
|
||||||
@@ -193,7 +193,7 @@ updateRBList w
|
|||||||
| w ^? rbOptions . opItemID == mcurrentitemid =
|
| w ^? rbOptions . opItemID == mcurrentitemid =
|
||||||
w & setEquipAllocation & setEquipActivation
|
w & setEquipAllocation & setEquipActivation
|
||||||
| otherwise = fromMaybe (w & rbOptions .~ NoRightButtonOptions) $ do
|
| otherwise = fromMaybe (w & rbOptions .~ NoRightButtonOptions) $ do
|
||||||
i <- cr ^? crManipulation . isel . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
esite <- cr ^? crInv . ix i . itUse . equipEffect . eeSite
|
esite <- cr ^? crInv . ix i . itUse . equipEffect . eeSite
|
||||||
itid <- mcurrentitemid
|
itid <- mcurrentitemid
|
||||||
return $
|
return $
|
||||||
@@ -210,14 +210,14 @@ updateRBList w
|
|||||||
& setEquipActivation
|
& setEquipActivation
|
||||||
where
|
where
|
||||||
mcurrentitemid = do
|
mcurrentitemid = do
|
||||||
i <- cr ^? crManipulation . isel . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
cr ^? crInv . ix i . itID
|
cr ^? crInv . ix i . itID
|
||||||
--curinvid = crSel cr
|
--curinvid = crSel cr
|
||||||
cr = you w
|
cr = you w
|
||||||
|
|
||||||
chooseEquipmentPosition :: Creature -> [EquipPosition] -> Int
|
chooseEquipmentPosition :: Creature -> [EquipPosition] -> Int
|
||||||
chooseEquipmentPosition cr eps = fromMaybe (chooseFreeSite cr eps) $ do
|
chooseEquipmentPosition cr eps = fromMaybe (chooseFreeSite cr eps) $ do
|
||||||
i <- cr ^? crManipulation . isel . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
ep <- cr ^? crInvEquipped . ix i
|
ep <- cr ^? crInvEquipped . ix i
|
||||||
elemIndex ep eps
|
elemIndex ep eps
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
|
|||||||
|
|
||||||
setEquipAllocation :: World -> World
|
setEquipAllocation :: World -> World
|
||||||
setEquipAllocation w = fromMaybe w $ do
|
setEquipAllocation w = fromMaybe w $ do
|
||||||
curpos <- you w ^? crManipulation . isel . ispItem
|
curpos <- you w ^? crManipulation . manObject . inInventory . ispItem
|
||||||
return $ case _rbOptions w of
|
return $ case _rbOptions w of
|
||||||
EquipOptions{_opEquip = es, _opSel = i} ->
|
EquipOptions{_opEquip = es, _opSel = i} ->
|
||||||
case you w ^? crInvEquipped . ix curpos of
|
case you w ^? crInvEquipped . ix curpos of
|
||||||
@@ -302,7 +302,7 @@ setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of
|
|||||||
Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||||
where
|
where
|
||||||
--invsel = crSel (you w)
|
--invsel = crSel (you w)
|
||||||
minvsel = cr ^? crManipulation . isel . ispItem
|
minvsel = cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
cr = you w
|
cr = you w
|
||||||
invselcanactivate = isJust $ do
|
invselcanactivate = isJust $ do
|
||||||
i <- minvsel
|
i <- minvsel
|
||||||
@@ -323,10 +323,10 @@ closeObjScrollDir x
|
|||||||
| otherwise = id
|
| otherwise = id
|
||||||
|
|
||||||
changeSwapInvSel :: Int -> World -> World
|
changeSwapInvSel :: Int -> World -> World
|
||||||
changeSwapInvSel k w = case you w ^? crManipulation . isel of
|
changeSwapInvSel k w = case you w ^? crManipulation . manObject of
|
||||||
Just (SelItem i _) -> w & cWorld . lWorld . creatures . ix 0 %~ updatecreature i
|
Just (InInventory (SelItem i _)) -> w & cWorld . lWorld . creatures . ix 0 %~ updatecreature i
|
||||||
Just (SelCloseObject i) -> w
|
Just (SelCloseObject i) -> w
|
||||||
& cWorld . lWorld . creatures . ix 0 . crManipulation . isel . ispCloseObject
|
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . ispCloseObject
|
||||||
.~ ((i - k) `mod` numCO)
|
.~ ((i - k) `mod` numCO)
|
||||||
& hud . closeObjects %~ swapIndices i ((i - k) `mod` numCO)
|
& hud . closeObjects %~ swapIndices i ((i - k) `mod` numCO)
|
||||||
_ -> w
|
_ -> w
|
||||||
@@ -334,7 +334,7 @@ changeSwapInvSel k w = case you w ^? crManipulation . isel of
|
|||||||
updatecreature i =
|
updatecreature i =
|
||||||
(crInv %~ IM.safeSwapKeys (i `mod` n) (swapi i))
|
(crInv %~ IM.safeSwapKeys (i `mod` n) (swapi i))
|
||||||
. (crLeftInvSel . lisMPos . _Just %~ updateLeftInvSel i)
|
. (crLeftInvSel . lisMPos . _Just %~ updateLeftInvSel i)
|
||||||
. (crManipulation . isel . ispItem %~ (`mod` n) . subtract k)
|
. (crManipulation . manObject . inInventory . ispItem %~ (`mod` n) . subtract k)
|
||||||
. (crInvEquipped %~ IM.safeSwapKeys i (swapi i))
|
. (crInvEquipped %~ IM.safeSwapKeys i (swapi i))
|
||||||
. swapSite i (swapi i)
|
. swapSite i (swapi i)
|
||||||
. swapSite (swapi i) i
|
. swapSite (swapi i) i
|
||||||
@@ -359,14 +359,14 @@ changeAugInvSel yi w
|
|||||||
|
|
||||||
setInvPosFromSS :: World -> World
|
setInvPosFromSS :: World -> World
|
||||||
setInvPosFromSS w = w
|
setInvPosFromSS w = w
|
||||||
& cWorld . lWorld . creatures . ix 0 . crManipulation . isel .~ thesel
|
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject .~ thesel
|
||||||
where
|
where
|
||||||
thesel = fromMaybe SelNothing $ do
|
thesel = fromMaybe SelNothing $ do
|
||||||
sss <- w ^? hud . hudElement . diSections
|
sss <- w ^? hud . hudElement . diSections
|
||||||
i <- sss ^? sssSelPos . _Just
|
i <- sss ^? sssSelPos . _Just
|
||||||
j <- sss ^? sssSections . ix i . ssCursor . _Just . scurSel
|
j <- sss ^? sssSections . ix i . ssCursor . _Just . scurSel
|
||||||
case i of
|
case i of
|
||||||
0 -> Just $ SelItem j NoInvSelAction
|
0 -> Just $ InInventory (SelItem j NoInvSelAction)
|
||||||
2 -> Just $ SelCloseObject j
|
2 -> Just $ SelCloseObject j
|
||||||
_ -> Just SelNothing
|
_ -> Just SelNothing
|
||||||
|
|
||||||
@@ -493,7 +493,7 @@ bestCloseObjectIndex w = findIndex f $ w ^. hud . closeObjects
|
|||||||
ycr = you w
|
ycr = you w
|
||||||
|
|
||||||
selectedCloseObject :: World -> Maybe (Int, Either FloorItem Button)
|
selectedCloseObject :: World -> Maybe (Int, Either FloorItem Button)
|
||||||
selectedCloseObject w = case you w ^? crManipulation . isel . ispCloseObject of
|
selectedCloseObject w = case you w ^? crManipulation . manObject . ispCloseObject of
|
||||||
Just i -> selectNthCloseObject w i
|
Just i -> selectNthCloseObject w i
|
||||||
Nothing -> selectNthCloseObject w =<< bestCloseObjectIndex w
|
Nothing -> selectNthCloseObject w =<< bestCloseObjectIndex w
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ tryPutItemInInv cid flit w = case maybeInvSlot of
|
|||||||
createAndSelectItem :: Item -> World -> World
|
createAndSelectItem :: Item -> World -> World
|
||||||
createAndSelectItem itm w = case createPutItem itm w of
|
createAndSelectItem itm w = case createPutItem itm w of
|
||||||
(Just i, w') -> w'
|
(Just i, w') -> w'
|
||||||
& cWorld . lWorld . creatures . ix 0 . crManipulation .~ Manipulator (SelItem i NoInvSelAction)
|
& cWorld . lWorld . creatures . ix 0 . crManipulation . manObject
|
||||||
|
.~ InInventory (SelItem i NoInvSelAction)
|
||||||
(Nothing, w') -> w'
|
(Nothing, w') -> w'
|
||||||
|
|
||||||
createPutItem :: Item -> World -> (Maybe Int, World)
|
createPutItem :: Item -> World -> (Maybe Int, World)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ invSelectionItem' cr i it = SelectionItem
|
|||||||
col = _itInvColor it
|
col = _itInvColor it
|
||||||
pics = take (itSlotsTaken it) . (++ replicate 10 "*") $ case _itCurseStatus it of
|
pics = take (itSlotsTaken it) . (++ replicate 10 "*") $ case _itCurseStatus it of
|
||||||
UndroppableIdentified -> itemDisplay it
|
UndroppableIdentified -> itemDisplay it
|
||||||
_ | cr ^? crManipulation . isel . ispItem == Just i -> selectedItemDisplay cr it
|
_ | cr ^? crManipulation . manObject . inInventory . ispItem == Just i -> selectedItemDisplay cr it
|
||||||
_ -> itemDisplay it
|
_ -> itemDisplay it
|
||||||
invSelectionItem :: Creature -> (Int,Item) -> SelectionItem ()
|
invSelectionItem :: Creature -> (Int,Item) -> SelectionItem ()
|
||||||
invSelectionItem cr (i,it) = SelectionItem
|
invSelectionItem cr (i,it) = SelectionItem
|
||||||
@@ -50,7 +50,7 @@ invSelectionItem cr (i,it) = SelectionItem
|
|||||||
col = _itInvColor it
|
col = _itInvColor it
|
||||||
pics = take (itSlotsTaken it) . (++ replicate 10 "*") $ case _itCurseStatus it of
|
pics = take (itSlotsTaken it) . (++ replicate 10 "*") $ case _itCurseStatus it of
|
||||||
UndroppableIdentified -> itemDisplay it
|
UndroppableIdentified -> itemDisplay it
|
||||||
_ | cr ^? crManipulation . isel . ispItem == Just i -> selectedItemDisplay cr it
|
_ | cr ^? crManipulation . manObject . inInventory . ispItem == Just i -> selectedItemDisplay cr it
|
||||||
_ -> itemDisplay it
|
_ -> itemDisplay it
|
||||||
--
|
--
|
||||||
closeObjectToSelectionItem :: Int -> Either FloorItem Button -> SelectionItem ()
|
closeObjectToSelectionItem :: Int -> Either FloorItem Button -> SelectionItem ()
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ showAutoRechargeProgress lc = case lc of
|
|||||||
ChargeableAmmo{} -> show (_wpCharge lc)
|
ChargeableAmmo{} -> show (_wpCharge lc)
|
||||||
|
|
||||||
showReloadProgress :: Creature -> HeldConsumption -> String
|
showReloadProgress :: Creature -> HeldConsumption -> String
|
||||||
showReloadProgress cr ic = case cr ^? crManipulation . isel . iselAction of
|
showReloadProgress cr ic = case cr ^? crManipulation . manObject . inInventory . iselAction of
|
||||||
Just (ReloadAction i la) -> show i ++ showLoadActionType la (_laLoaded ic)
|
Just (ReloadAction i la) -> show i ++ showLoadActionType la (_laLoaded ic)
|
||||||
_ -> case ic ^? laProgress . _Just . ix 0 of
|
_ -> case ic ^? laProgress . _Just . ix 0 of
|
||||||
Nothing -> show $ _laLoaded ic
|
Nothing -> show $ _laLoaded ic
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ shootLaser it cr = cWorld . lWorld . lasers .:~ lasRayAt (_lasColor $ _itParams
|
|||||||
pos = _crPos cr
|
pos = _crPos cr
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
|
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
dam = _lasDamage $ _itParams it
|
dam = _lasDamage $ _itParams it
|
||||||
|
|
||||||
-- this has the feel of a left click item
|
-- this has the feel of a left click item
|
||||||
@@ -153,7 +153,7 @@ circleLaser it cr w
|
|||||||
pos = _crPos cr +.+ rotateV dir (V2 0 (max 70 $ dist cpos mwp))
|
pos = _crPos cr +.+ rotateV dir (V2 0 (max 70 $ dist cpos mwp))
|
||||||
dir = fromIntegral (_lasCycle (_itParams it)) * pi / 1000
|
dir = fromIntegral (_lasCycle (_itParams it)) * pi / 1000
|
||||||
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
|
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
dam = _lasDamage $ _itParams it
|
dam = _lasDamage $ _itParams it
|
||||||
|
|
||||||
shootDualLaser :: Item -> Creature -> World -> World
|
shootDualLaser :: Item -> Creature -> World -> World
|
||||||
@@ -176,7 +176,7 @@ shootDualLaser it cr w =
|
|||||||
dirl = argV $ mwp' -.- posl
|
dirl = argV $ mwp' -.- posl
|
||||||
dirr = argV $ mwp' -.- posr
|
dirr = argV $ mwp' -.- posr
|
||||||
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
|
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
dam = _lasDamage $ _itParams it
|
dam = _lasDamage $ _itParams it
|
||||||
|
|
||||||
basicBeamAt :: Int -> World -> Color -> Int -> Float -> Point2 -> Float -> Beam
|
basicBeamAt :: Int -> World -> Color -> Int -> Float -> Point2 -> Float -> Beam
|
||||||
@@ -211,7 +211,7 @@ aTractorBeam _ cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos
|
|||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
|
outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
|
||||||
power = _attractionPower . _itParams $ _crInv cr IM.! itRef
|
power = _attractionPower . _itParams $ _crInv cr IM.! itRef
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
|
|
||||||
tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
|
tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
|
||||||
tractorBeamAt pos outpos dir power =
|
tractorBeamAt pos outpos dir power =
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ rateIncAB exeffFirst exeffCont eff item cr w
|
|||||||
fastRate = _rateMinMax . _heldDelay $ _itUse item
|
fastRate = _rateMinMax . _heldDelay $ _itUse item
|
||||||
startRate = _rateMaxMax . _heldDelay $ _itUse item
|
startRate = _rateMaxMax . _heldDelay $ _itUse item
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
pointItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
|
pointItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
|
||||||
currentRate = _rateMax (_heldDelay (_itUse item))
|
currentRate = _rateMax (_heldDelay (_itUse item))
|
||||||
repeatFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item)) == 1
|
repeatFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item)) == 1
|
||||||
@@ -215,7 +215,7 @@ withWarmUp soundID f item cr w
|
|||||||
& f item cr
|
& f item cr
|
||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
|
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
|
||||||
curWarmUp = _warmTime . _heldDelay $ _itUse item
|
curWarmUp = _warmTime . _heldDelay $ _itUse item
|
||||||
maxWarmUp = _warmMax . _heldDelay $ _itUse item
|
maxWarmUp = _warmMax . _heldDelay $ _itUse item
|
||||||
@@ -343,7 +343,7 @@ useAllAmmo eff item cr =
|
|||||||
eff item cr
|
eff item cr
|
||||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded .~ 0)
|
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded .~ 0)
|
||||||
where
|
where
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
|
|
||||||
useAmmoUpTo :: Int -> ChainEffect
|
useAmmoUpTo :: Int -> ChainEffect
|
||||||
useAmmoUpTo amAmount eff item cr =
|
useAmmoUpTo amAmount eff item cr =
|
||||||
@@ -352,14 +352,14 @@ useAmmoUpTo amAmount eff item cr =
|
|||||||
%~ (max 0 . subtract amAmount)
|
%~ (max 0 . subtract amAmount)
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
|
|
||||||
useAmmoAmount :: Int -> ChainEffect
|
useAmmoAmount :: Int -> ChainEffect
|
||||||
useAmmoAmount amAmount eff item cr =
|
useAmmoAmount amAmount eff item cr =
|
||||||
eff item cr
|
eff item cr
|
||||||
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded -~ amAmount)
|
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded -~ amAmount)
|
||||||
where
|
where
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
|
|
||||||
{- |
|
{- |
|
||||||
Applies a world effect after an item use cooldown check.
|
Applies a world effect after an item use cooldown check.
|
||||||
@@ -371,7 +371,7 @@ useTimeCheck f item cr w = case item ^? itUse . heldDelay . rateTime of
|
|||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
setUseTime = cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTime +~ userate
|
setUseTime = cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTime +~ userate
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
userate = fromMaybe 0 $ item ^? itUse . heldDelay . rateMax
|
userate = fromMaybe 0 $ item ^? itUse . heldDelay . rateMax
|
||||||
|
|
||||||
-- | Applies a world effect after a hammer position check.
|
-- | Applies a world effect after a hammer position check.
|
||||||
@@ -396,7 +396,7 @@ ammoUseCheck f item cr w
|
|||||||
| otherwise = w
|
| otherwise = w
|
||||||
where
|
where
|
||||||
cid = _crID cr
|
cid = _crID cr
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
|
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
|
||||||
fireCondition =
|
fireCondition =
|
||||||
crWeaponReady cr
|
crWeaponReady cr
|
||||||
@@ -453,12 +453,12 @@ withItem g f it = g it f it
|
|||||||
withItemUpdate' :: (Item -> Item) -> ChainEffect
|
withItemUpdate' :: (Item -> Item) -> ChainEffect
|
||||||
withItemUpdate' up f it cr = f (up it) cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
|
withItemUpdate' up f it cr = f (up it) cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
|
||||||
where
|
where
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
|
|
||||||
withItemUpdate :: (Item -> Item) -> (Item -> ChainEffect) -> ChainEffect
|
withItemUpdate :: (Item -> Item) -> (Item -> ChainEffect) -> ChainEffect
|
||||||
withItemUpdate up g f it cr = g it f it cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
|
withItemUpdate up g f it cr = g it f it cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
|
||||||
where
|
where
|
||||||
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
|
||||||
|
|
||||||
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
|
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
|
||||||
withTempLight time rad col eff item cr =
|
withTempLight time rad col eff item cr =
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ setRemoteDir cid itid pj w = w & cWorld . lWorld . projectiles . ix (_prjID pj)
|
|||||||
--i = _prjID pj
|
--i = _prjID pj
|
||||||
newdir
|
newdir
|
||||||
| SDL.ButtonRight `M.member` _mouseButtons (_input w)
|
| SDL.ButtonRight `M.member` _mouseButtons (_input w)
|
||||||
&& w ^? cWorld . lWorld . creatures . ix cid . crManipulation . isel . ispItem
|
&& w ^? cWorld . lWorld . creatures . ix cid . crManipulation . manObject . inInventory . ispItem
|
||||||
== w ^? cWorld . lWorld . itemLocations . ix itid . ipInvID
|
== w ^? cWorld . lWorld . itemLocations . ix itid . ipInvID
|
||||||
= (w ^. cWorld . camPos . camRot) + argV (_mousePos (_input w))
|
= (w ^. cWorld . camPos . camRot) + argV (_mousePos (_input w))
|
||||||
| otherwise = _prjDir pj
|
| otherwise = _prjDir pj
|
||||||
|
|||||||
+14
-14
@@ -14,17 +14,17 @@ crCancelReloading :: Creature -> Creature
|
|||||||
crCancelReloading cr =
|
crCancelReloading cr =
|
||||||
cr
|
cr
|
||||||
& updateProgress
|
& updateProgress
|
||||||
& crManipulation . isel . iselAction .~ NoInvSelAction
|
& crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
|
||||||
where
|
where
|
||||||
updateProgress = case crSel cr of
|
updateProgress = case crSel cr of
|
||||||
SelItem i _ -> crInv . ix i . itUse . heldConsumption . laProgress %~ const Nothing
|
InInventory (SelItem i _) -> crInv . ix i . itUse . heldConsumption . laProgress %~ const Nothing
|
||||||
_ -> id
|
_ -> id
|
||||||
|
|
||||||
stepReloading :: Creature -> Creature
|
stepReloading :: Creature -> Creature
|
||||||
stepReloading cr = case cr ^?! crManipulation . isel of
|
stepReloading cr = case cr ^? crManipulation . manObject . inInventory of
|
||||||
SelItem i (ReloadAction x la)
|
Just (SelItem i (ReloadAction x la))
|
||||||
| x > 0 ->
|
| x > 0 ->
|
||||||
cr & crManipulation . isel . iselAction . actionProgress -~ 1
|
cr & crManipulation . manObject . inInventory . iselAction . actionProgress -~ 1
|
||||||
| otherwise ->
|
| otherwise ->
|
||||||
cr
|
cr
|
||||||
& crInv . ix i . itUse . heldConsumption %~ doLoadAction la
|
& crInv . ix i . itUse . heldConsumption %~ doLoadAction la
|
||||||
@@ -33,22 +33,22 @@ stepReloading cr = case cr ^?! crManipulation . isel of
|
|||||||
_ -> cr
|
_ -> cr
|
||||||
|
|
||||||
tryNextLoadAction :: Creature -> Creature
|
tryNextLoadAction :: Creature -> Creature
|
||||||
tryNextLoadAction cr = case cr ^? crManipulation . isel of
|
tryNextLoadAction cr = case cr ^? crManipulation . manObject . inInventory of
|
||||||
Just (SelItem i _) -> case cr ^? crInv . ix i . itUse . heldConsumption . laProgress . _Just . ix 0 of
|
Just (SelItem i _) -> case cr ^? crInv . ix i . itUse . heldConsumption . laProgress . _Just . ix 0 of
|
||||||
Nothing -> cr & crManipulation . isel . iselAction .~ NoInvSelAction
|
Nothing -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
|
||||||
Just la ->
|
Just la ->
|
||||||
cr & crManipulation . isel . iselAction . actionProgress .~ _actionTime la
|
cr & crManipulation . manObject . inInventory . iselAction . actionProgress .~ _actionTime la
|
||||||
& crManipulation . isel . iselAction . reloadAction .~ la
|
& crManipulation . manObject . inInventory . iselAction . reloadAction .~ la
|
||||||
_ -> cr
|
_ -> cr
|
||||||
|
|
||||||
crToggleReloading :: Creature -> Creature
|
crToggleReloading :: Creature -> Creature
|
||||||
crToggleReloading cr = case cr ^? crManipulation . isel . iselAction of
|
crToggleReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
|
||||||
Just ReloadAction{} -> cr & crManipulation . isel . iselAction .~ NoInvSelAction
|
Just ReloadAction{} -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
|
||||||
_ -> cr & tryStartLoading
|
_ -> cr & tryStartLoading
|
||||||
|
|
||||||
tryStartLoading :: Creature -> Creature
|
tryStartLoading :: Creature -> Creature
|
||||||
tryStartLoading cr = fromMaybe cr $ do
|
tryStartLoading cr = fromMaybe cr $ do
|
||||||
i <- cr ^? crManipulation . isel . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
hc <- cr ^? crInv . ix i . itUse . heldConsumption
|
hc <- cr ^? crInv . ix i . itUse . heldConsumption
|
||||||
return $ startLoading hc cr
|
return $ startLoading hc cr
|
||||||
|
|
||||||
@@ -60,12 +60,12 @@ startLoading ic cr = case ic ^? laProgress . _Just . ix 0 of
|
|||||||
Just [] -> error "item has empty load cycle"
|
Just [] -> error "item has empty load cycle"
|
||||||
Just _ | _laLoaded ic >= _laMax ic -> cr
|
Just _ | _laLoaded ic >= _laMax ic -> cr
|
||||||
Just (la : las) -> fromMaybe (error "item loading error") $ do
|
Just (la : las) -> fromMaybe (error "item loading error") $ do
|
||||||
i <- cr ^? crManipulation . isel . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
return $ cr & startLoadingStep la
|
return $ cr & startLoadingStep la
|
||||||
& crInv . ix i . itUse . heldConsumption . laProgress ?~ (la : las)
|
& crInv . ix i . itUse . heldConsumption . laProgress ?~ (la : las)
|
||||||
|
|
||||||
startLoadingStep :: LoadAction -> Creature -> Creature
|
startLoadingStep :: LoadAction -> Creature -> Creature
|
||||||
startLoadingStep la cr = cr & crManipulation . isel . iselAction .~ ReloadAction (_actionTime la) la
|
startLoadingStep la cr = cr & crManipulation . manObject . inInventory . iselAction .~ ReloadAction (_actionTime la) la
|
||||||
|
|
||||||
rotateActionProgress :: HeldConsumption -> HeldConsumption
|
rotateActionProgress :: HeldConsumption -> HeldConsumption
|
||||||
rotateActionProgress ic = case ic ^? laProgress . _Just of
|
rotateActionProgress ic = case ic ^? laProgress . _Just of
|
||||||
|
|||||||
@@ -85,9 +85,10 @@ inventoryDisplay sss w cfig = listPicturesAtScaleOff
|
|||||||
spos <- _sssSelPos sss
|
spos <- _sssSelPos sss
|
||||||
sss ^? sssSections . ix spos . ssCursor . _Just . scurColor
|
sss ^? sssSections . ix spos . ssCursor . _Just . scurColor
|
||||||
thecursor = fromMaybe mempty $ do
|
thecursor = fromMaybe mempty $ do
|
||||||
sectype <- you w ^? crManipulation . isel
|
sectype <- you w ^? crManipulation . manObject
|
||||||
let secnum = case sectype of
|
let secnum = case sectype of
|
||||||
SelItem{} -> 0
|
InInventory SortInventory -> negate 1
|
||||||
|
InInventory {} -> 0
|
||||||
SelNothing{} -> 1
|
SelNothing{} -> 1
|
||||||
SelCloseObject{} -> 2
|
SelCloseObject{} -> 2
|
||||||
xint <- sss ^? sssSections . ix secnum . ssIndent
|
xint <- sss ^? sssSections . ix secnum . ssIndent
|
||||||
@@ -152,8 +153,8 @@ floorItemPickupInfo n itm
|
|||||||
-- note the use of ^?!
|
-- note the use of ^?!
|
||||||
-- it is probably desirable for this to crash hard for now
|
-- it is probably desirable for this to crash hard for now
|
||||||
yourAugmentedItem :: (Item -> a) -> a -> (Either FloorItem Button -> a) -> World -> a
|
yourAugmentedItem :: (Item -> a) -> a -> (Either FloorItem Button -> a) -> World -> a
|
||||||
yourAugmentedItem f x g w = case you w ^? crManipulation . isel of
|
yourAugmentedItem f x g w = case you w ^? crManipulation . manObject of
|
||||||
Just (SelItem i _) -> f $ yourInv w ^?! ix i
|
Just (InInventory (SelItem i _)) -> f $ yourInv w ^?! ix i
|
||||||
Just (SelCloseObject i) -> g $ w ^?! hud . closeObjects . ix i
|
Just (SelCloseObject i) -> g $ w ^?! hud . closeObjects . ix i
|
||||||
_ -> x
|
_ -> x
|
||||||
|
|
||||||
@@ -269,7 +270,7 @@ displayTerminal tid cfig w = fromMaybe mempty $ do
|
|||||||
drawRBOptions :: Configuration -> World -> RightButtonOptions -> Picture
|
drawRBOptions :: Configuration -> World -> RightButtonOptions -> Picture
|
||||||
drawRBOptions cfig w EquipOptions{_opEquip = es, _opSel = i, _opAllocateEquipment = ae}
|
drawRBOptions cfig w EquipOptions{_opEquip = es, _opSel = i, _opAllocateEquipment = ae}
|
||||||
= fromMaybe mempty $ do
|
= fromMaybe mempty $ do
|
||||||
curpos <- you w ^? crManipulation . isel . ispItem
|
curpos <- you w ^? crManipulation . manObject . inInventory . ispItem
|
||||||
let midtext str = listTextPictureAt 252 0 cfig curpos (text str)
|
let midtext str = listTextPictureAt 252 0 cfig curpos (text str)
|
||||||
let extratext str = listTextPictureAt 432 0 cfig curpos (text (str ++ deactivatetext))
|
let extratext str = listTextPictureAt 432 0 cfig curpos (text (str ++ deactivatetext))
|
||||||
return $ listPicturesAtOff 342 0 cfig (curpos - i) (map (text . eqPosText) es)
|
return $ listPicturesAtOff 342 0 cfig (curpos - i) (map (text . eqPosText) es)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ moveZoomCamera cfig theinput cr campos =
|
|||||||
where
|
where
|
||||||
cpos = _crPos cr
|
cpos = _crPos cr
|
||||||
mitm = do
|
mitm = do
|
||||||
i <- cr ^? crManipulation . isel . ispItem
|
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||||
cr ^? crInv . ix i
|
cr ^? crInv . ix i
|
||||||
newvf = cpos +.+ fromMaybe (V2 0 0) vfoffset
|
newvf = cpos +.+ fromMaybe (V2 0 0) vfoffset
|
||||||
vfoffset = do
|
vfoffset = do
|
||||||
@@ -87,7 +87,7 @@ moveZoomCamera cfig theinput cr campos =
|
|||||||
|
|
||||||
updateScopeZoom :: World -> World
|
updateScopeZoom :: World -> World
|
||||||
updateScopeZoom w = fromMaybe w $ do
|
updateScopeZoom w = fromMaybe w $ do
|
||||||
i <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . isel . ispItem
|
i <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . inInventory . ispItem
|
||||||
return $ updateScopeZoom' i w
|
return $ updateScopeZoom' i w
|
||||||
|
|
||||||
updateScopeZoom' :: Int -> World -> World
|
updateScopeZoom' :: Int -> World -> World
|
||||||
@@ -178,13 +178,14 @@ rotateCameraBy :: Float -> CWorld -> CWorld
|
|||||||
rotateCameraBy x w =
|
rotateCameraBy x w =
|
||||||
w
|
w
|
||||||
& camPos . camRot +~ x
|
& camPos . camRot +~ x
|
||||||
& fromMaybe id (do
|
& rotateanyscope
|
||||||
i <- w ^? lWorld . creatures . ix 0 . crManipulation . isel . ispItem
|
where
|
||||||
|
rotateanyscope = fromMaybe id $ do
|
||||||
|
i <- w ^? lWorld . creatures . ix 0 . crManipulation . manObject . inInventory . ispItem
|
||||||
return $ lWorld . creatures . ix 0 . crInv . ix i
|
return $ lWorld . creatures . ix 0 . crInv . ix i
|
||||||
. itScope
|
. itScope
|
||||||
. scopePos
|
. scopePos
|
||||||
%~ rotateV x
|
%~ rotateV x
|
||||||
)
|
|
||||||
|
|
||||||
rotateCamera :: Configuration -> World -> World
|
rotateCamera :: Configuration -> World -> World
|
||||||
rotateCamera cfig w
|
rotateCamera cfig w
|
||||||
@@ -195,8 +196,6 @@ rotateCamera cfig w
|
|||||||
where
|
where
|
||||||
keydown scode = scode `M.member` _pressedKeys (_input w) && not (inputFocus w)
|
keydown scode = scode `M.member` _pressedKeys (_input w) && not (inputFocus w)
|
||||||
|
|
||||||
--zoomCamBy :: Float -> World -> World
|
|
||||||
--zoomCamBy x w = w {_cameraZoom = max (_cameraZoom w + x) 0.01}
|
|
||||||
zoomFromItem ::
|
zoomFromItem ::
|
||||||
ItZoom ->
|
ItZoom ->
|
||||||
Float
|
Float
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ moveTweakSel i w = case yourItem w ^? _Just . itTweaks . tweakParams of
|
|||||||
|
|
||||||
changeTweakParam :: Maybe Int -> Int -> World -> World
|
changeTweakParam :: Maybe Int -> Int -> World -> World
|
||||||
changeTweakParam mi i w = fromMaybe w $ do
|
changeTweakParam mi i w = fromMaybe w $ do
|
||||||
curpos <- you w ^? crManipulation . isel . ispItem
|
curpos <- you w ^? crManipulation . manObject . inInventory . ispItem
|
||||||
paramid <- mi
|
paramid <- mi
|
||||||
params <- yourItem w ^? _Just . itTweaks . tweakParams . ix paramid
|
params <- yourItem w ^? _Just . itTweaks . tweakParams . ix paramid
|
||||||
let x = (_tweakVal params + i) `mod` _tweakMax params
|
let x = (_tweakVal params + i) `mod` _tweakMax params
|
||||||
|
|||||||
Reference in New Issue
Block a user