Commit before changing ItemUse into single product type
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -47,7 +47,7 @@ followImpulse cr w imp = case imp of
|
||||
TurnToward p a -> crup $ creatureTurnToward p a cr
|
||||
TurnTo p -> crup $ creatureTurnTo p cr
|
||||
ChangePosture post -> crup $ cr & crStance . posture .~ post
|
||||
UseItem -> (useRootItem $ _crID cr, cr)
|
||||
UseItem -> (useSelectedItem $ _crID cr, cr)
|
||||
SwitchToItem i -> crup $ cr & crManipulation . manObject .~ SelectedItem i i mempty
|
||||
Melee cid' ->
|
||||
( hitCr cid'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module Dodge.Creature.Impulse.UseItem (
|
||||
useRootItem,
|
||||
useSelectedItem,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
@@ -16,11 +16,13 @@ import Dodge.Item.Grammar
|
||||
import Dodge.Item.Location
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
useRootItem :: Int -> World -> World
|
||||
useRootItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
|
||||
useSelectedItem :: Int -> World -> World
|
||||
useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix crid
|
||||
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
invid <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
itmtree <- invRootTrees (_crInv cr) ^? ix itRef
|
||||
itmloc <- allInvLocs (_crInv cr) ^? ix invid
|
||||
let itm = itmtree ^. ldtValue . _1
|
||||
case itmtree ^. ldtValue . _2 of
|
||||
HeldPlatformSF ->
|
||||
|
||||
@@ -173,18 +173,21 @@ mouseActionsCr pkeys
|
||||
|
||||
pressedMBEffectsTopInventory :: M.Map SDL.MouseButton Int -> World -> World
|
||||
pressedMBEffectsTopInventory pkeys w
|
||||
| isDown SDL.ButtonLeft && isDown SDL.ButtonRight && inTopInv = youhammerdown $ useRootItem 0 w
|
||||
-- | isDown SDL.ButtonLeft && inTopInv = youhammerdown $ useItemLeftClick (you w) w
|
||||
| isDown SDL.ButtonMiddle = w & wCam . camRot -~ rotation
|
||||
| Just ltime <- pkeys ^? ix SDL.ButtonLeft
|
||||
, Just rtime <- pkeys ^? ix SDL.ButtonRight
|
||||
, ltime <= rtime && inTopInv
|
||||
= youhammerdown $ useSelectedItem 0 w
|
||||
| Just _ <- pkeys ^? ix SDL.ButtonLeft
|
||||
, Just _ <- pkeys ^? ix SDL.ButtonRight
|
||||
= w & wCam . camRot -~ rotation
|
||||
| otherwise = w
|
||||
where
|
||||
youhammerdown = set (cWorld . lWorld . creatures . ix 0 . crHammerPosition) HammerDown
|
||||
inTopInv = case w ^. hud . hudElement of
|
||||
DisplayInventory{_subInventory = NoSubInventory{}} -> True
|
||||
_ -> False
|
||||
isDown but = but `M.member` pkeys
|
||||
rotation =
|
||||
maybe
|
||||
0
|
||||
(angleBetween $ w ^. input . mousePos)
|
||||
(w ^. input . heldPos . at SDL.ButtonMiddle)
|
||||
(w ^. input . heldPos . at SDL.ButtonRight)
|
||||
|
||||
@@ -41,14 +41,8 @@ data ItemUse
|
||||
, _heldParams :: HeldParams
|
||||
, _heldTriggerType :: TriggerType
|
||||
, _useCondition :: UseCondition
|
||||
, _useFocus :: UseFocus
|
||||
}
|
||||
-- | UseHotkey
|
||||
-- { _leftUse :: Luse
|
||||
-- , _leftDelay :: UseDelay
|
||||
-- , _leftHammer :: HammerPosition
|
||||
-- , _uequipEffect :: EquipEffect
|
||||
-- , _leftConsumption :: LeftConsumption
|
||||
-- }
|
||||
| UseConsume { _cUse :: Cuse }
|
||||
| UseEquip { _uequipEffect :: EquipEffect }
|
||||
| UseAttach {_uaParams :: AttachParams}
|
||||
@@ -57,6 +51,11 @@ data ItemUse
|
||||
| UseBulletMod { _ubMod :: BulletMod }
|
||||
deriving (Eq, Show, Read)
|
||||
|
||||
data UseFocus
|
||||
= UseFromRoot
|
||||
| UseFromLocation
|
||||
deriving (Eq, Show, Read)
|
||||
|
||||
data UseCondition
|
||||
= MustBeHeld
|
||||
| UseableAnytime
|
||||
@@ -204,6 +203,8 @@ makeLenses ''AmmoParams
|
||||
makeLenses ''MuzzleEffect
|
||||
makeLenses ''AmmoPerShot
|
||||
makeLenses ''UseCondition
|
||||
makeLenses ''UseFocus
|
||||
deriveJSON defaultOptions ''UseFocus
|
||||
deriveJSON defaultOptions ''UseCondition
|
||||
deriveJSON defaultOptions ''MuzzleEffect
|
||||
deriveJSON defaultOptions ''FlareType
|
||||
|
||||
@@ -43,4 +43,5 @@ defaultHeldUse = UseHeld
|
||||
}
|
||||
, _heldTriggerType = HammerTrigger
|
||||
, _useCondition = MustBeHeld
|
||||
, _useFocus = UseFromRoot
|
||||
}
|
||||
|
||||
+5
-10
@@ -28,7 +28,8 @@ tinMag :: Item
|
||||
tinMag =
|
||||
defaultHeldItem & itType .~ AMMOMAG TINMAG
|
||||
& itUse .~ UseNothing
|
||||
& itConsumables .~ AmmoMag
|
||||
& itConsumables
|
||||
.~ AmmoMag
|
||||
{ _magParams = BulletParams defaultBullet
|
||||
, _magType = BulletAmmo
|
||||
, _magLoadStatus =
|
||||
@@ -38,13 +39,6 @@ tinMag =
|
||||
}
|
||||
}
|
||||
|
||||
--revolveMag :: Item
|
||||
--revolveMag =
|
||||
-- tinMag
|
||||
-- & itType .~ AMMOMAG REVOLVEMAG
|
||||
-- & itUse . amagLoadStatus . iaMax .~ 6
|
||||
-- & itUse . amagLoadStatus . iaLoaded .~ 6
|
||||
|
||||
drumMag :: Item
|
||||
drumMag =
|
||||
tinMag & itType . ibtAmmoMag .~ DRUMMAG
|
||||
@@ -125,5 +119,6 @@ chemFuelPouch =
|
||||
}
|
||||
|
||||
bulletSynthesizer :: Item
|
||||
bulletSynthesizer = makeAttach BULLETSYNTH
|
||||
& itUse .~ UseAttach (APInt 0)
|
||||
bulletSynthesizer =
|
||||
makeAttach BULLETSYNTH
|
||||
& itUse .~ UseAttach (APInt 0)
|
||||
|
||||
@@ -90,6 +90,9 @@ itemToFunction itm = case itm ^. itType of
|
||||
HELD{} -> case itm ^? itUse . useCondition of
|
||||
Just MustBeHeld -> HeldPlatformSF
|
||||
_ -> GadgetPlatformSF
|
||||
_ | Just amtype <- itm ^? itConsumables . magType
|
||||
, Just _ <- itm ^? itLocation . ilEquipSite . _Just
|
||||
-> AmmoMagSF amtype
|
||||
AMMOMAG{} -> maybe UncomposableIsolateSF AmmoMagSF $ itm ^? itConsumables . magType
|
||||
ATTACH REMOTESCREEN -> RemoteScreenSF
|
||||
ATTACH BULLETSYNTH -> AmmoModifierSF BulletAmmo
|
||||
|
||||
Reference in New Issue
Block a user