Cleanup
This commit is contained in:
@@ -45,45 +45,34 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
|||||||
PutOnEquipment{_allocNewPos = newp} ->
|
PutOnEquipment{_allocNewPos = newp} ->
|
||||||
w
|
w
|
||||||
& crpoint . crEquipment . at newp ?~ invid
|
& crpoint . crEquipment . at newp ?~ invid
|
||||||
-- & crpoint . crInvEquipped . at invid ?~ newp
|
& crpoint . crInv . ix invid . itLocation . ilEquipSite ?~ newp
|
||||||
& crpoint . crInv . ix invid . itLocation . ilEquipPosition ?~ newp
|
|
||||||
& onequip itm cr
|
& onequip itm cr
|
||||||
-- & crpoint %~ assignNewHotkey invid
|
|
||||||
& cWorld . lWorld %~ assignNewHotkey invid
|
& cWorld . lWorld %~ assignNewHotkey invid
|
||||||
MoveEquipment{_allocNewPos = newp, _allocOldPos = oldp} ->
|
MoveEquipment{_allocNewPos = newp, _allocOldPos = oldp} ->
|
||||||
w
|
w
|
||||||
& crpoint . crEquipment . at newp ?~ invid
|
& crpoint . crEquipment . at newp ?~ invid
|
||||||
& crpoint . crEquipment . at oldp .~ Nothing
|
& crpoint . crEquipment . at oldp .~ Nothing
|
||||||
-- & crpoint . crInvEquipped . at invid ?~ newp
|
& crpoint . crInv . ix invid . itLocation . ilEquipSite ?~ newp
|
||||||
& crpoint . crInv . ix invid . itLocation . ilEquipPosition ?~ newp
|
|
||||||
SwapEquipment{_allocNewPos = newp, _allocOldPos = oldp, _allocSwapID = sid} ->
|
SwapEquipment{_allocNewPos = newp, _allocOldPos = oldp, _allocSwapID = sid} ->
|
||||||
w
|
w
|
||||||
& crpoint . crEquipment . at newp ?~ invid
|
& crpoint . crEquipment . at newp ?~ invid
|
||||||
& crpoint . crEquipment . at oldp ?~ sid
|
& crpoint . crEquipment . at oldp ?~ sid
|
||||||
-- & crpoint . crInvEquipped . at invid ?~ newp
|
& crpoint . crInv . ix invid . itLocation . ilEquipSite ?~ newp
|
||||||
& crpoint . crInv . ix invid . itLocation . ilEquipPosition ?~ newp
|
& crpoint . crInv . ix sid . itLocation . ilEquipSite ?~ oldp
|
||||||
-- & crpoint . crInvEquipped . at sid ?~ oldp
|
|
||||||
& crpoint . crInv . ix sid . itLocation . ilEquipPosition ?~ oldp
|
|
||||||
ReplaceEquipment{_allocNewPos = newp, _allocRemoveID = rid} ->
|
ReplaceEquipment{_allocNewPos = newp, _allocRemoveID = rid} ->
|
||||||
w
|
w
|
||||||
& crpoint . crEquipment . at newp ?~ invid
|
& crpoint . crEquipment . at newp ?~ invid
|
||||||
-- & crpoint . crInvEquipped . at invid ?~ newp
|
& crpoint . crInv . ix invid . itLocation . ilEquipSite ?~ newp
|
||||||
& crpoint . crInv . ix invid . itLocation . ilEquipPosition ?~ newp
|
& crpoint . crInv . ix rid . itLocation . ilEquipSite .~ Nothing
|
||||||
-- & crpoint . crInvEquipped . at rid .~ Nothing
|
|
||||||
& crpoint . crInv . ix rid . itLocation . ilEquipPosition .~ Nothing
|
|
||||||
& onremove (itmat rid) cr
|
& onremove (itmat rid) cr
|
||||||
& onequip itm cr
|
& onequip itm cr
|
||||||
-- & crpoint %~ removeHotkey rid
|
|
||||||
-- & crpoint %~ assignNewHotkey invid
|
|
||||||
& cWorld . lWorld %~ removeHotkey rid
|
& cWorld . lWorld %~ removeHotkey rid
|
||||||
& cWorld . lWorld %~ assignNewHotkey invid
|
& cWorld . lWorld %~ assignNewHotkey invid
|
||||||
RemoveEquipment{_allocOldPos = oldp} ->
|
RemoveEquipment{_allocOldPos = oldp} ->
|
||||||
w
|
w
|
||||||
& crpoint . crEquipment . at oldp .~ Nothing
|
& crpoint . crEquipment . at oldp .~ Nothing
|
||||||
-- & crpoint . crInvEquipped . at invid .~ Nothing
|
& crpoint . crInv . ix invid . itLocation . ilEquipSite .~ Nothing
|
||||||
& crpoint . crInv . ix invid . itLocation . ilEquipPosition .~ Nothing
|
|
||||||
& onremove itm cr
|
& onremove itm cr
|
||||||
-- & crpoint %~ removeHotkey invid
|
|
||||||
& cWorld . lWorld %~ removeHotkey invid
|
& cWorld . lWorld %~ removeHotkey invid
|
||||||
where
|
where
|
||||||
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
|
|||||||
itm = loc ^. locLDT . ldtValue . _1
|
itm = loc ^. locLDT . ldtValue . _1
|
||||||
|
|
||||||
doAnyEquipmentEffect :: LocationLDT ItemLink ComposedItem -> Creature -> World -> World
|
doAnyEquipmentEffect :: LocationLDT ItemLink ComposedItem -> Creature -> World -> World
|
||||||
doAnyEquipmentEffect loc cr = case itm ^? itLocation . ilEquipPosition . _Just of
|
doAnyEquipmentEffect loc cr = case itm ^? itLocation . ilEquipSite . _Just of
|
||||||
Just _ -> useE loc cr
|
Just _ -> useE loc cr
|
||||||
_ -> id
|
_ -> id
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ equipmentStrValue itm = case _itType itm of
|
|||||||
_ -> 0
|
_ -> 0
|
||||||
|
|
||||||
crCurrentEquipment :: Creature -> IM.IntMap Item
|
crCurrentEquipment :: Creature -> IM.IntMap Item
|
||||||
crCurrentEquipment = IM.filter (isJust . (^? itLocation . ilEquipPosition . _Just)) . _crInv
|
crCurrentEquipment = IM.filter (isJust . (^? itLocation . ilEquipSite . _Just)) . _crInv
|
||||||
|
|
||||||
strFromHeldItem :: Creature -> Int
|
strFromHeldItem :: Creature -> Int
|
||||||
strFromHeldItem cr
|
strFromHeldItem cr
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ data Creature = Creature
|
|||||||
, _crManipulation :: Manipulation
|
, _crManipulation :: Manipulation
|
||||||
, _crInvCapacity :: Int
|
, _crInvCapacity :: Int
|
||||||
, _crInvLock :: Bool
|
, _crInvLock :: Bool
|
||||||
, _crEquipment :: M.Map EquipPosition Int
|
, _crEquipment :: M.Map EquipSite Int
|
||||||
, _crState :: CreatureState
|
, _crState :: CreatureState
|
||||||
, _crCorpse :: CreatureCorpse --Creature -> Corpse -> SPic
|
, _crCorpse :: CreatureCorpse --Creature -> Corpse -> SPic
|
||||||
, _crMaterial :: Material
|
, _crMaterial :: Material
|
||||||
|
|||||||
@@ -8,16 +8,17 @@ module Dodge.Data.Equipment.Misc where
|
|||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import Data.Aeson.TH
|
import Data.Aeson.TH
|
||||||
|
|
||||||
data EquipSite
|
data EquipType
|
||||||
= GoesOnHead
|
= GoesOnHead
|
||||||
| GoesOnChest
|
| GoesOnChest
|
||||||
| GoesOnBack
|
| GoesOnBack
|
||||||
| GoesOnWrist
|
| GoesOnWrist
|
||||||
| GoesOnLegs
|
| GoesOnLegs
|
||||||
deriving (Eq,Ord,Show,Read)
|
deriving (Eq, Ord, Show, Read)
|
||||||
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
|
||||||
|
|
||||||
data EquipPosition
|
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
|
data EquipSite
|
||||||
= OnHead
|
= OnHead
|
||||||
| OnChest
|
| OnChest
|
||||||
| OnBack
|
| OnBack
|
||||||
@@ -25,9 +26,11 @@ data EquipPosition
|
|||||||
| OnRightWrist
|
| OnRightWrist
|
||||||
| OnLegs
|
| OnLegs
|
||||||
| OnSpecial
|
| OnSpecial
|
||||||
deriving (Eq, Ord,Show,Read)
|
deriving (Eq, Ord, Show, Read)
|
||||||
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
|
||||||
data Hotkey = HotkeyQ
|
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
data Hotkey
|
||||||
|
= HotkeyQ
|
||||||
| HotkeyE
|
| HotkeyE
|
||||||
| Hotkey1
|
| Hotkey1
|
||||||
| Hotkey2
|
| Hotkey2
|
||||||
@@ -39,13 +42,16 @@ data Hotkey = HotkeyQ
|
|||||||
| Hotkey8
|
| Hotkey8
|
||||||
| Hotkey9
|
| Hotkey9
|
||||||
| Hotkey0
|
| Hotkey0
|
||||||
deriving (Eq, Show, Read, Ord, Bounded, Enum) --Generic, Flat)
|
deriving (Eq, Show, Read, Ord, Bounded, Enum) --Generic, Flat)
|
||||||
|
|
||||||
|
|
||||||
|
deriveJSON defaultOptions ''EquipType
|
||||||
deriveJSON defaultOptions ''EquipSite
|
deriveJSON defaultOptions ''EquipSite
|
||||||
deriveJSON defaultOptions ''EquipPosition
|
|
||||||
deriveJSON defaultOptions ''Hotkey
|
deriveJSON defaultOptions ''Hotkey
|
||||||
instance ToJSONKey EquipPosition
|
|
||||||
instance FromJSONKey EquipPosition
|
instance ToJSONKey EquipSite
|
||||||
|
|
||||||
|
instance FromJSONKey EquipSite
|
||||||
|
|
||||||
instance ToJSONKey Hotkey
|
instance ToJSONKey Hotkey
|
||||||
|
|
||||||
instance FromJSONKey Hotkey
|
instance FromJSONKey Hotkey
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ data EquipItemType
|
|||||||
| FLAMESHIELD
|
| FLAMESHIELD
|
||||||
| FRONTARMOUR
|
| FRONTARMOUR
|
||||||
| WRISTARMOUR
|
| WRISTARMOUR
|
||||||
| INVISIBILITYEQUIPMENT EquipSite
|
| INVISIBILITYEQUIPMENT EquipType
|
||||||
| BRAINHAT
|
| BRAINHAT
|
||||||
| HAT
|
| HAT
|
||||||
| HEADLAMP
|
| HEADLAMP
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ data ItEffect = ItEffect
|
|||||||
|
|
||||||
data ItInvEffect
|
data ItInvEffect
|
||||||
= NoInvEffect
|
= NoInvEffect
|
||||||
-- | ChargeIfEquipped
|
|
||||||
-- | ChargeIfInInventory
|
|
||||||
-- | SetCharge Int
|
|
||||||
| EffectRootNotroot ItInvEffect ItInvEffect
|
| EffectRootNotroot ItInvEffect ItInvEffect
|
||||||
| CreateShieldWall
|
| CreateShieldWall
|
||||||
| RemoveShieldWall
|
| RemoveShieldWall
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ data ItemLocation
|
|||||||
, _ilIsRoot :: Bool
|
, _ilIsRoot :: Bool
|
||||||
, _ilIsSelected :: Bool
|
, _ilIsSelected :: Bool
|
||||||
, _ilIsAttached :: Bool
|
, _ilIsAttached :: Bool
|
||||||
, _ilEquipPosition :: Maybe EquipPosition
|
, _ilEquipSite :: Maybe EquipSite
|
||||||
}
|
}
|
||||||
| OnTurret {_ilTuID :: Int}
|
| OnTurret {_ilTuID :: Int}
|
||||||
| OnFloor {_ilFlID :: NewInt FloorInt}
|
| OnFloor {_ilFlID :: NewInt FloorInt}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ data EquipEffect = EquipEffect
|
|||||||
{ _eeUse :: Euse --Item -> Creature -> World -> World
|
{ _eeUse :: Euse --Item -> Creature -> World -> World
|
||||||
, _eeOnEquip :: ItmCrWdWd --Item -> Creature -> World -> World
|
, _eeOnEquip :: ItmCrWdWd --Item -> Creature -> World -> World
|
||||||
, _eeOnRemove :: ItmCrWdWd --Item -> Creature -> World -> World
|
, _eeOnRemove :: ItmCrWdWd --Item -> Creature -> World -> World
|
||||||
, _eeSite :: EquipSite
|
, _eeType :: EquipType
|
||||||
, _eeParams :: EquipParams
|
, _eeParams :: EquipParams
|
||||||
, _eeViewDist :: Maybe Float
|
, _eeViewDist :: Maybe Float
|
||||||
, _eeAttachPos :: Point3
|
, _eeAttachPos :: Point3
|
||||||
|
|||||||
@@ -18,23 +18,23 @@ data RightButtonOptions
|
|||||||
data EquipmentAllocation
|
data EquipmentAllocation
|
||||||
= DoNotMoveEquipment
|
= DoNotMoveEquipment
|
||||||
| PutOnEquipment
|
| PutOnEquipment
|
||||||
{ _allocNewPos :: EquipPosition
|
{ _allocNewPos :: EquipSite
|
||||||
}
|
}
|
||||||
| MoveEquipment
|
| MoveEquipment
|
||||||
{ _allocNewPos :: EquipPosition
|
{ _allocNewPos :: EquipSite
|
||||||
, _allocOldPos :: EquipPosition
|
, _allocOldPos :: EquipSite
|
||||||
}
|
}
|
||||||
| SwapEquipment
|
| SwapEquipment
|
||||||
{ _allocNewPos :: EquipPosition
|
{ _allocNewPos :: EquipSite
|
||||||
, _allocOldPos :: EquipPosition
|
, _allocOldPos :: EquipSite
|
||||||
, _allocSwapID :: Int
|
, _allocSwapID :: Int
|
||||||
}
|
}
|
||||||
| ReplaceEquipment
|
| ReplaceEquipment
|
||||||
{ _allocNewPos :: EquipPosition
|
{ _allocNewPos :: EquipSite
|
||||||
, _allocRemoveID :: Int
|
, _allocRemoveID :: Int
|
||||||
}
|
}
|
||||||
| RemoveEquipment
|
| RemoveEquipment
|
||||||
{ _allocOldPos :: EquipPosition
|
{ _allocOldPos :: EquipSite
|
||||||
}
|
}
|
||||||
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Dodge.Data.Item.Use.Equipment
|
|||||||
defaultEquip :: EquipEffect
|
defaultEquip :: EquipEffect
|
||||||
defaultEquip =
|
defaultEquip =
|
||||||
EquipEffect
|
EquipEffect
|
||||||
{ _eeSite = GoesOnHead
|
{ _eeType = GoesOnHead
|
||||||
, _eeUse = EDoNothing
|
, _eeUse = EDoNothing
|
||||||
, _eeOnEquip = ItmCrWdWdDoNothing
|
, _eeOnEquip = ItmCrWdWdDoNothing
|
||||||
, _eeOnRemove = ItmCrWdWdDoNothing
|
, _eeOnRemove = ItmCrWdWdDoNothing
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ module Dodge.Equipment.Text (eqPosText) where
|
|||||||
|
|
||||||
import Dodge.Data.Equipment.Misc
|
import Dodge.Data.Equipment.Misc
|
||||||
|
|
||||||
eqPosText :: EquipPosition -> String
|
eqPosText :: EquipSite -> String
|
||||||
eqPosText ep = case ep of
|
eqPosText ep = case ep of
|
||||||
OnHead -> "HEAD"
|
OnHead -> "HEAD"
|
||||||
OnChest -> "CHESt"
|
OnChest -> "CHESt"
|
||||||
|
|||||||
+1
-1
@@ -104,7 +104,7 @@ setWristShieldPos itm cr w = w & moveWallIDUnsafe i wlline
|
|||||||
i = _eparamID $ _eeParams $ _uequipEffect $ _itUse itm
|
i = _eparamID $ _eeParams $ _uequipEffect $ _itUse itm
|
||||||
wlline = (f (V3 (-10) 7 0), f (V3 10 7 0))
|
wlline = (f (V3 (-10) 7 0), f (V3 10 7 0))
|
||||||
invid = _ilInvID (_itLocation itm)
|
invid = _ilInvID (_itLocation itm)
|
||||||
handtrans = case cr ^? crInv . ix invid . itLocation . ilEquipPosition . _Just of
|
handtrans = case cr ^? crInv . ix invid . itLocation . ilEquipSite . _Just of
|
||||||
Just OnLeftWrist -> \cr' -> translatePointToLeftHand cr' . g
|
Just OnLeftWrist -> \cr' -> translatePointToLeftHand cr' . g
|
||||||
_ -> translatePointToRightHand
|
_ -> translatePointToRightHand
|
||||||
g
|
g
|
||||||
|
|||||||
@@ -22,13 +22,10 @@ newHotkey lw = fromMaybe maxBound $
|
|||||||
|
|
||||||
-- this will not remove the hotkey from its old slot, assumes there is a hotkey
|
-- this will not remove the hotkey from its old slot, assumes there is a hotkey
|
||||||
-- to swap with instead
|
-- to swap with instead
|
||||||
-- requires there actually is equipment in the slot, too
|
|
||||||
assignHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
assignHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
||||||
assignHotkey invid hk lw = fromMaybe lw $ do
|
assignHotkey invid hk lw = fromMaybe lw $ do
|
||||||
--guard (invid `IM.member` (cr ^. crInvEquipped))
|
|
||||||
guard $ lw ^? creatures . ix 0 . crInv . ix invid . itUse . useCondition
|
guard $ lw ^? creatures . ix 0 . crInv . ix invid . itUse . useCondition
|
||||||
== Just UseableAnytime
|
== Just UseableAnytime
|
||||||
-- _ <- lw ^? creatures . ix 0 . crInv . ix invid . itUse . leftUse
|
|
||||||
return $ (setHotkey invid hk . moveOldHotkey invid hk) lw
|
return $ (setHotkey invid hk . moveOldHotkey invid hk) lw
|
||||||
|
|
||||||
moveOldHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
moveOldHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
||||||
|
|||||||
@@ -66,10 +66,7 @@ rmInvItem cid invid w =
|
|||||||
& pointcid . crInv %~ f -- important
|
& pointcid . crInv %~ f -- important
|
||||||
& removeAnySlotEquipment
|
& removeAnySlotEquipment
|
||||||
& pointcid . crEquipment . each %~ g
|
& pointcid . crEquipment . each %~ g
|
||||||
-- & pointcid . crInvEquipped %~ IM.delete invid
|
|
||||||
-- & pointcid . crInvEquipped %~ IM.mapKeys g
|
|
||||||
& removeanyactivation
|
& removeanyactivation
|
||||||
-- & pointcid . crHotkeys . each %~ g
|
|
||||||
& cWorld . lWorld . hotkeys . each %~ g
|
& cWorld . lWorld . hotkeys . each %~ g
|
||||||
& cWorld . lWorld . imHotkeys %~ IM.delete invid
|
& cWorld . lWorld . imHotkeys %~ IM.delete invid
|
||||||
& cWorld . lWorld . imHotkeys %~ IM.mapKeys g
|
& cWorld . lWorld . imHotkeys %~ IM.mapKeys g
|
||||||
@@ -96,13 +93,11 @@ rmInvItem cid invid w =
|
|||||||
rmf <- itm ^? itEffect . ieOnDrop
|
rmf <- itm ^? itEffect . ieOnDrop
|
||||||
return $ doInvEffect rmf itm cr
|
return $ doInvEffect rmf itm cr
|
||||||
removeAnySlotEquipment = fromMaybe id $ do
|
removeAnySlotEquipment = fromMaybe id $ do
|
||||||
--epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvEquipped . ix invid
|
|
||||||
epos <- w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
|
epos <- w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
|
||||||
. itLocation . ilEquipPosition . _Just
|
. itLocation . ilEquipSite . _Just
|
||||||
return $ pointcid . crEquipment . at epos .~ Nothing
|
return $ pointcid . crEquipment . at epos .~ Nothing
|
||||||
removeanyactivation = fromMaybe id $ do
|
removeanyactivation = fromMaybe id $ do
|
||||||
epos <- w ^? cWorld . lWorld . imHotkeys . ix invid
|
epos <- w ^? cWorld . lWorld . imHotkeys . ix invid
|
||||||
--return $ pointcid . crHotkeys . at epos .~ Nothing
|
|
||||||
return $ cWorld . lWorld . hotkeys . at epos .~ Nothing
|
return $ cWorld . lWorld . hotkeys . at epos .~ Nothing
|
||||||
maxk = fmap fst $ IM.lookupMax $ cr ^. crInv
|
maxk = fmap fst $ IM.lookupMax $ cr ^. crInv
|
||||||
f inv =
|
f inv =
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ tryPutItemInInv cid flit w = case maybeInvSlot of
|
|||||||
, _ilIsRoot = False
|
, _ilIsRoot = False
|
||||||
, _ilIsSelected = False
|
, _ilIsSelected = False
|
||||||
, _ilIsAttached = False
|
, _ilIsAttached = False
|
||||||
, _ilEquipPosition = Nothing
|
, _ilEquipSite = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
---- should select the item on the floor if no inventory space?
|
---- should select the item on the floor if no inventory space?
|
||||||
|
|||||||
@@ -72,9 +72,8 @@ crUpdateInvidLocations mo crid lw invid itm =
|
|||||||
, _ilIsRoot = Just invid == mo ^? imRootSelectedItem
|
, _ilIsRoot = Just invid == mo ^? imRootSelectedItem
|
||||||
, _ilIsSelected = Just invid == mo ^? imSelectedItem
|
, _ilIsSelected = Just invid == mo ^? imSelectedItem
|
||||||
, _ilIsAttached = invid `IS.member` (mo ^. imAttachedItems)
|
, _ilIsAttached = invid `IS.member` (mo ^. imAttachedItems)
|
||||||
--, _ilEquipPosition = lw ^? creatures . ix crid . crInvEquipped . ix invid
|
, _ilEquipSite = lw ^? creatures . ix crid . crInv . ix invid
|
||||||
, _ilEquipPosition = lw ^? creatures . ix crid . crInv . ix invid
|
. itLocation . ilEquipSite . _Just
|
||||||
. itLocation . ilEquipPosition . _Just
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- this should be looked at, as it is sometimes used in functions that need not
|
-- this should be looked at, as it is sometimes used in functions that need not
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module Dodge.Inventory.RBList (
|
module Dodge.Inventory.RBList (
|
||||||
updateRBList,
|
updateRBList,
|
||||||
getEquipmentAllocation,
|
getEquipmentAllocation,
|
||||||
equipSiteToPositions,
|
eqSiteToPositions,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Applicative
|
import Control.Applicative
|
||||||
@@ -14,32 +14,30 @@ import Dodge.Data.World
|
|||||||
import qualified SDL
|
import qualified SDL
|
||||||
|
|
||||||
updateRBList :: World -> World
|
updateRBList :: World -> World
|
||||||
updateRBList w
|
updateRBList w = case w ^. rbOptions of
|
||||||
| not (SDL.ButtonRight `M.member` (w ^. input . mouseButtons)) =
|
_ | norightclick -> w & rbOptions .~ NoRightButtonOptions
|
||||||
w & rbOptions .~ NoRightButtonOptions
|
EquipOptions{} -> w
|
||||||
| otherwise = case w ^. rbOptions of
|
_ -> fromMaybe (w & rbOptions .~ NoRightButtonOptions) $ do
|
||||||
EquipOptions{} -> w
|
i <- cr ^? crManipulation . manObject . imSelectedItem
|
||||||
_ -> fromMaybe (w & rbOptions .~ NoRightButtonOptions) $ do
|
esite <- cr ^? crInv . ix i . itUse . uequipEffect . eeType
|
||||||
i <- cr ^? crManipulation . manObject . imSelectedItem
|
return $
|
||||||
esite <- cr ^? crInv . ix i . itUse . uequipEffect . eeSite
|
w & rbOptions
|
||||||
return $
|
.~ EquipOptions
|
||||||
w
|
{ _opSel = chooseEquipPosition cr (eqSiteToPositions esite)
|
||||||
& rbOptions
|
}
|
||||||
.~ EquipOptions
|
|
||||||
{ _opSel = chooseEquipmentPosition cr (equipSiteToPositions esite)
|
|
||||||
}
|
|
||||||
where
|
where
|
||||||
|
norightclick = not $ SDL.ButtonRight `M.member` (w ^. input . mouseButtons)
|
||||||
cr = you w
|
cr = you w
|
||||||
|
|
||||||
-- want to choose the current position if the item is equipped, otherwise try to
|
-- want to choose the current position if the item is equipped, otherwise try to
|
||||||
-- find a free equipment slot
|
-- find a free equipment slot
|
||||||
chooseEquipmentPosition :: Creature -> [EquipPosition] -> Int
|
chooseEquipPosition :: Creature -> [EquipSite] -> Int
|
||||||
chooseEquipmentPosition cr eps = fromMaybe (chooseFreeSite cr eps) $ do
|
chooseEquipPosition cr eps = fromMaybe (chooseFreeSite cr eps) $ do
|
||||||
i <- cr ^? crManipulation . manObject . imSelectedItem
|
i <- cr ^? crManipulation . manObject . imSelectedItem
|
||||||
ep <- cr ^? crInv . ix i . itLocation . ilEquipPosition . _Just
|
ep <- cr ^? crInv . ix i . itLocation . ilEquipSite . _Just
|
||||||
elemIndex ep eps
|
elemIndex ep eps
|
||||||
|
|
||||||
chooseFreeSite :: Creature -> [EquipPosition] -> Int
|
chooseFreeSite :: Creature -> [EquipSite] -> Int
|
||||||
chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
|
chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
|
||||||
where
|
where
|
||||||
hasnoequipment ep = isNothing $ cr ^? crEquipment . ix ep
|
hasnoequipment ep = isNothing $ cr ^? crEquipment . ix ep
|
||||||
@@ -47,11 +45,12 @@ chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
|
|||||||
getEquipmentAllocation :: World -> EquipmentAllocation
|
getEquipmentAllocation :: World -> EquipmentAllocation
|
||||||
getEquipmentAllocation w = fromMaybe DoNotMoveEquipment $ do
|
getEquipmentAllocation w = fromMaybe DoNotMoveEquipment $ do
|
||||||
curpos <- you w ^? crManipulation . manObject . imSelectedItem
|
curpos <- you w ^? crManipulation . manObject . imSelectedItem
|
||||||
esite <- you w ^? crInv . ix curpos . itUse . uequipEffect . eeSite
|
esite <- you w ^? crInv . ix curpos . itUse . uequipEffect . eeType
|
||||||
i <- w ^? rbOptions . opSel
|
i <-
|
||||||
<|> Just (chooseEquipmentPosition (you w) (equipSiteToPositions esite))
|
w ^? rbOptions . opSel
|
||||||
es <- equipSiteToPositions esite ^? ix i
|
<|> Just (chooseEquipPosition (you w) (eqSiteToPositions esite))
|
||||||
return $ case you w ^? crInv . ix curpos . itLocation . ilEquipPosition . _Just of
|
es <- eqSiteToPositions esite ^? ix i
|
||||||
|
return $ case you w ^? crInv . ix curpos . itLocation . ilEquipSite . _Just of
|
||||||
Just epos
|
Just epos
|
||||||
| es == epos -> RemoveEquipment{_allocOldPos = epos}
|
| es == epos -> RemoveEquipment{_allocOldPos = epos}
|
||||||
Just epos
|
Just epos
|
||||||
@@ -74,11 +73,10 @@ getEquipmentAllocation w = fromMaybe DoNotMoveEquipment $ do
|
|||||||
}
|
}
|
||||||
Nothing -> PutOnEquipment{_allocNewPos = es}
|
Nothing -> PutOnEquipment{_allocNewPos = es}
|
||||||
|
|
||||||
equipSiteToPositions :: EquipSite -> [EquipPosition]
|
eqSiteToPositions :: EquipType -> [EquipSite]
|
||||||
equipSiteToPositions es = case es of
|
eqSiteToPositions es = case es of
|
||||||
GoesOnHead -> [OnHead]
|
GoesOnHead -> [OnHead]
|
||||||
GoesOnChest -> [OnChest]
|
GoesOnChest -> [OnChest]
|
||||||
GoesOnBack -> [OnBack]
|
GoesOnBack -> [OnBack]
|
||||||
GoesOnWrist -> [OnLeftWrist, OnRightWrist]
|
GoesOnWrist -> [OnLeftWrist, OnRightWrist]
|
||||||
GoesOnLegs -> [OnLegs]
|
GoesOnLegs -> [OnLegs]
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ invSelectionItem indent lw i ci =
|
|||||||
cr = lw ^?! creatures . ix 0
|
cr = lw ^?! creatures . ix 0
|
||||||
anyhotkey = maybe [] ((' ' :) . hotkeyToString) (lw ^? imHotkeys . ix i)
|
anyhotkey = maybe [] ((' ' :) . hotkeyToString) (lw ^? imHotkeys . ix i)
|
||||||
anyequippos = maybe [] (rightPad 8 ' ' . (' ' :) . eqPosText)
|
anyequippos = maybe [] (rightPad 8 ' ' . (' ' :) . eqPosText)
|
||||||
(ci ^? _1 . itLocation . ilEquipPosition . _Just)
|
(ci ^? _1 . itLocation . ilEquipSite . _Just)
|
||||||
col = itemInvColor ci
|
col = itemInvColor ci
|
||||||
pics = itemDisplay cr ci
|
pics = itemDisplay cr ci
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ swapInvItems f i w = fromMaybe w $ do
|
|||||||
. (cWorld . lWorld . imHotkeys %~ IM.safeSwapKeys i k)
|
. (cWorld . lWorld . imHotkeys %~ IM.safeSwapKeys i k)
|
||||||
cr = you w
|
cr = you w
|
||||||
--swapSite a b = case cr ^? crInvEquipped . ix a of
|
--swapSite a b = case cr ^? crInvEquipped . ix a of
|
||||||
swapSite a b = case cr ^? crInv . ix a . itLocation . ilEquipPosition . _Just of
|
swapSite a b = case cr ^? crInv . ix a . itLocation . ilEquipSite . _Just of
|
||||||
Just epos -> crEquipment . ix epos .~ b
|
Just epos -> crEquipment . ix epos .~ b
|
||||||
Nothing -> id
|
Nothing -> id
|
||||||
--swapSite' a b = case cr ^? crInvHotkeys . ix a of
|
--swapSite' a b = case cr ^? crInvHotkeys . ix a of
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
{-# LANGUAGE LambdaCase #-}
|
||||||
module Dodge.ItEffect (
|
module Dodge.ItEffect (
|
||||||
doInvEffect,
|
doInvEffect,
|
||||||
) where
|
) where
|
||||||
@@ -7,7 +8,7 @@ import Dodge.Data.World
|
|||||||
import Dodge.Euse
|
import Dodge.Euse
|
||||||
|
|
||||||
doInvEffect :: ItInvEffect -> Item -> Creature -> World -> World
|
doInvEffect :: ItInvEffect -> Item -> Creature -> World -> World
|
||||||
doInvEffect iie = case iie of
|
doInvEffect = \case
|
||||||
NoInvEffect -> const $ const id
|
NoInvEffect -> const $ const id
|
||||||
EffectRootNotroot f g -> rootNotrootEff f g
|
EffectRootNotroot f g -> rootNotrootEff f g
|
||||||
CreateShieldWall -> createShieldWall
|
CreateShieldWall -> createShieldWall
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ itemEquipPict cr itmtree = case itm ^. itUse of
|
|||||||
ituse -> fold $ do
|
ituse -> fold $ do
|
||||||
attachpos <- ituse ^? uequipEffect . eeAttachPos
|
attachpos <- ituse ^? uequipEffect . eeAttachPos
|
||||||
i <- itm ^? itLocation . ilInvID
|
i <- itm ^? itLocation . ilInvID
|
||||||
epos <- cr ^? crInv . ix i . itLocation . ilEquipPosition . _Just
|
epos <- cr ^? crInv . ix i . itLocation . ilEquipSite . _Just
|
||||||
return $ equipPosition epos cr attachpos (itemSPic itm)
|
return $ equipPosition epos cr attachpos (itemSPic itm)
|
||||||
where
|
where
|
||||||
itm = itmtree ^. ldtValue . _1
|
itm = itmtree ^. ldtValue . _1
|
||||||
|
|
||||||
equipPosition :: EquipPosition -> Creature -> Point3 -> SPic -> SPic
|
equipPosition :: EquipSite -> Creature -> Point3 -> SPic -> SPic
|
||||||
equipPosition epos cr p sh = case epos of
|
equipPosition epos cr p sh = case epos of
|
||||||
OnLeftWrist -> translateToLeftWrist cr sh
|
OnLeftWrist -> translateToLeftWrist cr sh
|
||||||
OnRightWrist -> translateToRightWrist cr sh
|
OnRightWrist -> translateToRightWrist cr sh
|
||||||
|
|||||||
+14
-14
@@ -28,25 +28,25 @@ magShield =
|
|||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itParams .~ MagShieldParams Nothing
|
& itParams .~ MagShieldParams Nothing
|
||||||
& itUse . uequipEffect . eeUse .~ EMagShield
|
& itUse . uequipEffect . eeUse .~ EMagShield
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnWrist
|
& itUse . uequipEffect . eeType .~ GoesOnWrist
|
||||||
& itType .~ EQUIP MAGSHIELD
|
& itType .~ EQUIP MAGSHIELD
|
||||||
|
|
||||||
flameShield :: Item
|
flameShield :: Item
|
||||||
flameShield =
|
flameShield =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnChest
|
& itUse . uequipEffect . eeType .~ GoesOnChest
|
||||||
& itType .~ EQUIP FLAMESHIELD
|
& itType .~ EQUIP FLAMESHIELD
|
||||||
|
|
||||||
frontArmour :: Item
|
frontArmour :: Item
|
||||||
frontArmour =
|
frontArmour =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnChest
|
& itUse . uequipEffect . eeType .~ GoesOnChest
|
||||||
& itType .~ EQUIP FRONTARMOUR
|
& itType .~ EQUIP FRONTARMOUR
|
||||||
|
|
||||||
wristArmour :: Item
|
wristArmour :: Item
|
||||||
wristArmour =
|
wristArmour =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnWrist
|
& itUse . uequipEffect . eeType .~ GoesOnWrist
|
||||||
& itUse . uequipEffect . eeOnEquip .~ EonWristShield
|
& itUse . uequipEffect . eeOnEquip .~ EonWristShield
|
||||||
& itUse . uequipEffect . eeUse .~ EWristShield
|
& itUse . uequipEffect . eeUse .~ EWristShield
|
||||||
& itUse . uequipEffect . eeOnRemove .~ EoffWristShield
|
& itUse . uequipEffect . eeOnRemove .~ EoffWristShield
|
||||||
@@ -55,7 +55,7 @@ wristArmour =
|
|||||||
batteryPack :: Item
|
batteryPack :: Item
|
||||||
batteryPack =
|
batteryPack =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnBack
|
& itUse . uequipEffect . eeType .~ GoesOnBack
|
||||||
& itUse . uequipEffect . eeAttachPos .~ V3 (-8) 0 10
|
& itUse . uequipEffect . eeAttachPos .~ V3 (-8) 0 10
|
||||||
& itUse . uequipEffect . eeUse .~ EDoNothing
|
& itUse . uequipEffect . eeUse .~ EDoNothing
|
||||||
& itConsumables
|
& itConsumables
|
||||||
@@ -73,7 +73,7 @@ batteryPack =
|
|||||||
fuelPack :: Item
|
fuelPack :: Item
|
||||||
fuelPack =
|
fuelPack =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnBack
|
& itUse . uequipEffect . eeType .~ GoesOnBack
|
||||||
& itUse . uequipEffect . eeAttachPos .~ V3 (-9) 0 10
|
& itUse . uequipEffect . eeAttachPos .~ V3 (-9) 0 10
|
||||||
-- & itUse . uequipEffect . eeUse .~ EFuelSource 10000 10000
|
-- & itUse . uequipEffect . eeUse .~ EFuelSource 10000 10000
|
||||||
& itType .~ EQUIP FUELPACK
|
& itType .~ EQUIP FUELPACK
|
||||||
@@ -91,7 +91,7 @@ fuelPack =
|
|||||||
bulletBeltPack :: Item
|
bulletBeltPack :: Item
|
||||||
bulletBeltPack =
|
bulletBeltPack =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnBack
|
& itUse . uequipEffect . eeType .~ GoesOnBack
|
||||||
& itUse . uequipEffect . eeAttachPos .~ V3 (-9) 0 10
|
& itUse . uequipEffect . eeAttachPos .~ V3 (-9) 0 10
|
||||||
& itUse . uequipEffect . eeUse .~ EDoNothing
|
& itUse . uequipEffect . eeUse .~ EDoNothing
|
||||||
& itConsumables
|
& itConsumables
|
||||||
@@ -109,7 +109,7 @@ bulletBeltPack =
|
|||||||
bulletBeltBracer :: Item
|
bulletBeltBracer :: Item
|
||||||
bulletBeltBracer =
|
bulletBeltBracer =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnWrist
|
& itUse . uequipEffect . eeType .~ GoesOnWrist
|
||||||
& itUse . uequipEffect . eeAttachPos .~ V3 (-9) 0 10
|
& itUse . uequipEffect . eeAttachPos .~ V3 (-9) 0 10
|
||||||
& itUse . uequipEffect . eeUse .~ EDoNothing
|
& itUse . uequipEffect . eeUse .~ EDoNothing
|
||||||
& itConsumables
|
& itConsumables
|
||||||
@@ -127,26 +127,26 @@ bulletBeltBracer =
|
|||||||
brainHat :: Item
|
brainHat :: Item
|
||||||
brainHat =
|
brainHat =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnHead
|
& itUse . uequipEffect . eeType .~ GoesOnHead
|
||||||
& itType .~ EQUIP BRAINHAT
|
& itType .~ EQUIP BRAINHAT
|
||||||
|
|
||||||
hat :: Item
|
hat :: Item
|
||||||
hat =
|
hat =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnHead
|
& itUse . uequipEffect . eeType .~ GoesOnHead
|
||||||
& itType .~ EQUIP HAT
|
& itType .~ EQUIP HAT
|
||||||
|
|
||||||
headLamp :: Item
|
headLamp :: Item
|
||||||
headLamp =
|
headLamp =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeUse .~ EHeadLamp
|
& itUse . uequipEffect . eeUse .~ EHeadLamp
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnHead
|
& itUse . uequipEffect . eeType .~ GoesOnHead
|
||||||
& itType .~ EQUIP HEADLAMP
|
& itType .~ EQUIP HEADLAMP
|
||||||
|
|
||||||
powerLegs :: Item
|
powerLegs :: Item
|
||||||
powerLegs =
|
powerLegs =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnLegs
|
& itUse . uequipEffect . eeType .~ GoesOnLegs
|
||||||
& itType .~ EQUIP POWERLEGS
|
& itType .~ EQUIP POWERLEGS
|
||||||
|
|
||||||
speedLegs :: Item
|
speedLegs :: Item
|
||||||
@@ -158,7 +158,7 @@ jumpLegs = powerLegs & itType .~ EQUIP JUMPLEGS
|
|||||||
wristInvisibility :: Item
|
wristInvisibility :: Item
|
||||||
wristInvisibility =
|
wristInvisibility =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnWrist
|
& itUse . uequipEffect . eeType .~ GoesOnWrist
|
||||||
-- & itUse . uequipEffect . eeOnEquip .~ ECamouflage Invisible
|
-- & itUse . uequipEffect . eeOnEquip .~ ECamouflage Invisible
|
||||||
-- & itUse . uequipEffect . eeOnRemove .~ ECamouflage FullyVisible
|
-- & itUse . uequipEffect . eeOnRemove .~ ECamouflage FullyVisible
|
||||||
& itType .~ EQUIP (INVISIBILITYEQUIPMENT GoesOnWrist)
|
& itType .~ EQUIP (INVISIBILITYEQUIPMENT GoesOnWrist)
|
||||||
@@ -166,5 +166,5 @@ wristInvisibility =
|
|||||||
pulseChecker :: Item
|
pulseChecker :: Item
|
||||||
pulseChecker =
|
pulseChecker =
|
||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . uequipEffect . eeSite .~ GoesOnWrist
|
& itUse . uequipEffect . eeType .~ GoesOnWrist
|
||||||
& itType .~ EQUIP WRIST_ECG
|
& itType .~ EQUIP WRIST_ECG
|
||||||
|
|||||||
@@ -210,9 +210,9 @@ aimStanceInfo as = case as of
|
|||||||
OneHand -> "It is held in one hand."
|
OneHand -> "It is held in one hand."
|
||||||
|
|
||||||
itmEquipSiteInfo :: Item -> String
|
itmEquipSiteInfo :: Item -> String
|
||||||
itmEquipSiteInfo = maybe "" equipSiteInfo . (^? itUse . uequipEffect . eeSite)
|
itmEquipSiteInfo = maybe "" equipSiteInfo . (^? itUse . uequipEffect . eeType)
|
||||||
|
|
||||||
equipSiteInfo :: EquipSite -> String
|
equipSiteInfo :: EquipType -> String
|
||||||
equipSiteInfo es = case es of
|
equipSiteInfo es = case es of
|
||||||
GoesOnHead -> " on the head"
|
GoesOnHead -> " on the head"
|
||||||
GoesOnChest -> " on the chest"
|
GoesOnChest -> " on the chest"
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ initCrItemLocation cr invid w it = (w & itemLocations . at locid ?~ loc
|
|||||||
, _ilIsRoot = False
|
, _ilIsRoot = False
|
||||||
, _ilIsSelected = False
|
, _ilIsSelected = False
|
||||||
, _ilIsAttached = False
|
, _ilIsAttached = False
|
||||||
, _ilEquipPosition = Nothing
|
, _ilEquipSite = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -239,8 +239,8 @@ drawRBOptions cfig w = fromMaybe mempty $ do
|
|||||||
guard $ ButtonRight `M.member` _mouseButtons (_input w)
|
guard $ ButtonRight `M.member` _mouseButtons (_input w)
|
||||||
invid <- you w ^? crManipulation . manObject . imSelectedItem
|
invid <- you w ^? crManipulation . manObject . imSelectedItem
|
||||||
eslist <-
|
eslist <-
|
||||||
fmap equipSiteToPositions $
|
fmap eqSiteToPositions $
|
||||||
you w ^? crInv . ix invid . itUse . uequipEffect . eeSite
|
you w ^? crInv . ix invid . itUse . uequipEffect . eeType
|
||||||
i <- w ^? rbOptions . opSel
|
i <- w ^? rbOptions . opSel
|
||||||
let ae = getEquipmentAllocation w
|
let ae = getEquipmentAllocation w
|
||||||
sss <- w ^? hud . hudElement . diSections
|
sss <- w ^? hud . hudElement . diSections
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
|
|||||||
where
|
where
|
||||||
rbscrollmax = fromMaybe 1 $ do
|
rbscrollmax = fromMaybe 1 $ do
|
||||||
invid <- you w ^? crManipulation . manObject . imSelectedItem
|
invid <- you w ^? crManipulation . manObject . imSelectedItem
|
||||||
esite <- you w ^? crInv . ix invid . itUse . uequipEffect . eeSite
|
esite <- you w ^? crInv . ix invid . itUse . uequipEffect . eeType
|
||||||
return $ length $ equipSiteToPositions esite
|
return $ length $ eqSiteToPositions esite
|
||||||
y = fromIntegral yi
|
y = fromIntegral yi
|
||||||
numLocs = (fst . IM.findMax $ (w ^. cWorld . lWorld . seenLocations)) + 1
|
numLocs = (fst . IM.findMax $ (w ^. cWorld . lWorld . seenLocations)) + 1
|
||||||
bdown b = b `M.member` _mouseButtons (_input w)
|
bdown b = b `M.member` _mouseButtons (_input w)
|
||||||
|
|||||||
Reference in New Issue
Block a user