Commit before tweaking item id/locations
This commit is contained in:
@@ -5,6 +5,7 @@ module Dodge.Creature.Impulse.UseItem (
|
||||
useItemHotkey,
|
||||
) where
|
||||
|
||||
import Dodge.SelectUse
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
@@ -40,17 +41,14 @@ itemEffect cr it w = case it ^. ldtValue . itUse of
|
||||
EquipUse{} -> doequipmentchange
|
||||
(ConsumeUse eff) -> useC eff (_ldtValue it) cr w
|
||||
CraftUse{} -> w
|
||||
AttachUse{} -> w
|
||||
AttachUse{} -> selectUse it cr w
|
||||
AmmoMagUse{} -> w
|
||||
where
|
||||
itm = it ^. ldtValue
|
||||
hammerTest f = case _crHammerPosition cr of
|
||||
HammerUp -> f w -- & setuhamdown
|
||||
_ -> w -- & setuhamdown
|
||||
-- setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
|
||||
doequipmentchange = fromMaybe w $ do
|
||||
guard (_crHammerPosition cr == HammerUp)
|
||||
invid <- itm ^? itLocation . ipInvID
|
||||
return $ hammerTest $ toggleEquipmentAt invid cr
|
||||
return $ toggleEquipmentAt invid cr w
|
||||
|
||||
toggleEquipmentAt :: Int -> Creature -> World -> World
|
||||
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
||||
|
||||
@@ -215,9 +215,8 @@ pressedMBEffectsTopInventory pkeys w
|
||||
DisplayInventory{_subInventory = NoSubInventory} -> True
|
||||
_ -> False
|
||||
isDown but = but `M.member` pkeys
|
||||
theinput = w ^. input
|
||||
rotation =
|
||||
maybe
|
||||
0
|
||||
(angleBetween (theinput ^. mousePos))
|
||||
(theinput ^. heldPos . at SDL.ButtonMiddle)
|
||||
(angleBetween $ w ^. input . mousePos)
|
||||
(w ^. input . heldPos . at SDL.ButtonMiddle)
|
||||
|
||||
@@ -60,6 +60,7 @@ data ItemUse
|
||||
| CraftUse
|
||||
| -- {_useAmount :: ItAmount}
|
||||
AttachUse
|
||||
{_atLinkedProjectile :: Maybe Int}
|
||||
| -- {_attachParams :: AttachParams}
|
||||
AmmoMagUse
|
||||
{ _amagLoadStatus :: ReloadStatus
|
||||
|
||||
@@ -62,6 +62,7 @@ rmInvItem cid invid w = w
|
||||
& updateselection
|
||||
& pointcid %~ updateRootItemID
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
& updateCreatureItemLocations cid
|
||||
where
|
||||
pointcid = cWorld . lWorld . creatures . ix cid
|
||||
|
||||
@@ -94,6 +95,15 @@ rmInvItem cid invid w = w
|
||||
| x > invid || Just x == maxk = max 0 $ x - 1
|
||||
| otherwise = x
|
||||
|
||||
updateCreatureItemLocations :: Int -> World -> World
|
||||
updateCreatureItemLocations crid w = fromMaybe w $ do
|
||||
inv <- w ^? cWorld . lWorld . creatures . ix crid . crInv
|
||||
return $ foldl' updateItemLocation w inv
|
||||
|
||||
updateItemLocation :: World -> Item -> World
|
||||
updateItemLocation w itm = w
|
||||
& cWorld . lWorld . itemLocations . ix (itm ^. itID) .~ itm ^. itLocation
|
||||
|
||||
---- | after this the item at the inventory position will no longer exist
|
||||
--rmInvItem ::
|
||||
-- -- | Creature id
|
||||
|
||||
@@ -104,9 +104,9 @@ chemFuelPouch =
|
||||
bulletSynthesizer :: Item
|
||||
bulletSynthesizer = defaultHeldItem
|
||||
& itType . iyBase .~ ATTACH BULLETSYNTHESIZER
|
||||
& itUse .~ AttachUse
|
||||
& itUse .~ AttachUse Nothing
|
||||
|
||||
rocketHomer :: Item
|
||||
rocketHomer = defaultHeldItem
|
||||
& itType . iyBase .~ ATTACH ROCKETHOMER
|
||||
& itUse .~ AttachUse
|
||||
& itUse .~ AttachUse Nothing
|
||||
|
||||
@@ -19,10 +19,10 @@ targetingScope :: TargetType -> Item
|
||||
targetingScope tt =
|
||||
defaultHeldItem
|
||||
& itType . iyBase .~ ATTACH (TARGETATTACH tt)
|
||||
& itUse .~ AttachUse
|
||||
& itUse .~ AttachUse Nothing
|
||||
|
||||
rocketRemoteScreen :: Item
|
||||
rocketRemoteScreen =
|
||||
defaultHeldItem
|
||||
& itType . iyBase .~ ATTACH ROCKETREMOTESCREEN
|
||||
& itUse .~ AttachUse
|
||||
& itUse .~ AttachUse Nothing
|
||||
|
||||
@@ -20,7 +20,8 @@ import Dodge.Data.Universe
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
testStringInit :: Universe -> [String]
|
||||
testStringInit _ = mempty
|
||||
testStringInit u = map show $
|
||||
(IM.toList . IM.filter (\itloc -> itloc ^? ipCrID == Just 0) $ (u ^. uvWorld . cWorld . lWorld . itemLocations)) <> IM.toList ( fmap _itLocation (u ^?! uvWorld . cWorld . lWorld . creatures . ix 0 . crInv))
|
||||
--testStringInit u = fromMaybe mempty $ do
|
||||
-- inv <- fmap invLDT $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crInv
|
||||
-- invitm <- inv ^? ix 1
|
||||
|
||||
Reference in New Issue
Block a user