Remove _ilIsSelected
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
module Dodge.Creature.Impulse.UseItem (useItem) where
|
||||
|
||||
import qualified Data.IntSet as IS
|
||||
import Dodge.Euse
|
||||
import NewInt
|
||||
import Control.Lens
|
||||
@@ -28,7 +29,10 @@ useItem invid pt w = fmap (worldEventFlags . at InventoryChange ?~ ()) $ do
|
||||
useItemLoc :: Creature -> LocationDT OItem -> Int -> World -> Maybe World
|
||||
useItemLoc cr loc pt w
|
||||
| aimuse
|
||||
, fromMaybe False $ loc ^? locDT . dtValue . _1 . itLocation . ilIsAttached
|
||||
, fromMaybe False $ do
|
||||
i <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID . unNInt
|
||||
is <- w ^? hud . manObject . hiAttachedItems
|
||||
return $ i `IS.member` is
|
||||
, Aiming{} <- cr ^. crStance . posture =
|
||||
return $ gadgetEffect pt loc cr w
|
||||
| GadgetPlatformSF <- sf =
|
||||
|
||||
@@ -4,6 +4,7 @@ module Dodge.Creature.State (
|
||||
invItemEffs,
|
||||
) where
|
||||
|
||||
import qualified Data.IntSet as IS
|
||||
import Dodge.Creature.Radius
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Linear
|
||||
@@ -106,19 +107,23 @@ invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
|
||||
HELD MINIGUNX{} -> coolMinigun itm w
|
||||
HELD MACHINEPISTOL{} -> coolMachinePistol cr itm w
|
||||
LASER | loc ^. locDT . dtValue . _2 == WeaponTargetingSF
|
||||
, itm ^? itLocation . ilIsAttached == Just True -> shineTargetLaser cr loc w
|
||||
, isattached -> shineTargetLaser cr loc w
|
||||
HELD LED
|
||||
| itm ^? itLocation . ilIsAttached == Just True -> shineTorch cr loc w
|
||||
| isattached -> shineTorch cr loc w
|
||||
TARGETING tt
|
||||
| itm ^? itLocation . ilIsAttached == Just True -> updateItemTargeting tt cr itm w
|
||||
| isattached -> updateItemTargeting tt cr itm w
|
||||
ARHUD
|
||||
| itm ^? itLocation . ilIsAttached == Just True -> drawARHUD loc w
|
||||
| isattached -> drawARHUD loc w
|
||||
_ -> w
|
||||
where
|
||||
haspulse =
|
||||
w ^? cWorld . lWorld . creatures . ix 0 . crType . avatarPulse . pulseProgress
|
||||
== Just 0
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
isattached = fromMaybe False $ do
|
||||
i <- itm ^? itLocation . ilInvID . unNInt
|
||||
is <- w ^? hud . manObject . hiAttachedItems
|
||||
return $ i `IS.member` is
|
||||
|
||||
coolMinigun :: Item -> World -> World
|
||||
coolMinigun itm
|
||||
@@ -312,7 +317,10 @@ updateItemTargeting tt cr itm w = case tt of
|
||||
where
|
||||
pointittarg = cWorld . lWorld . items . ix itid . itTargeting
|
||||
itid = itm ^. itID . unNInt
|
||||
isattached = itm ^?! itLocation . ilIsAttached
|
||||
isattached = fromMaybe False $ do
|
||||
i <- itm ^? itLocation . ilInvID . unNInt
|
||||
is <- w ^? hud . manObject . hiAttachedItems
|
||||
return $ i `IS.member` is
|
||||
rbpressed = SDL.ButtonRight `M.member` _mouseButtons (_input w)
|
||||
|
||||
setRBCreatureTargeting :: Creature -> World -> ItemTargeting -> ItemTargeting
|
||||
|
||||
@@ -31,7 +31,7 @@ data ItemLocation
|
||||
, _ilInvID :: NewInt InvInt
|
||||
, _ilIsRoot :: Bool -- of any item
|
||||
, _ilIsSelected :: Bool
|
||||
, _ilIsAttached :: Bool -- to selected item. question: downwards and upwards?
|
||||
-- , _ilIsAttached :: Bool -- to selected item. question: downwards and upwards?
|
||||
, _ilEquipSite :: Maybe EquipSite
|
||||
}
|
||||
| OnTurret {_ilTuID :: Int}
|
||||
@@ -40,14 +40,12 @@ data ItemLocation
|
||||
deriving (Eq, Show, Ord, Read) --Generic, Flat)
|
||||
|
||||
instance ShortShow ItemLocation where
|
||||
shortShow (InInv cid invid rootb selb attb esite) =
|
||||
shortShow (InInv cid invid rootb selb esite) =
|
||||
"InInv:cid" <> shortShow cid <> "invid" <> shortShow (_unNInt invid)
|
||||
<> "root"
|
||||
<> shortShow rootb
|
||||
<> "sel"
|
||||
<> shortShow selb
|
||||
<> "att"
|
||||
<> shortShow attb
|
||||
<> shortShow (fmap (SString . show) esite)
|
||||
shortShow x = show x
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ tryPutItemInInv mcipos itid w = do
|
||||
, _ilInvID = invid
|
||||
, _ilIsRoot = False
|
||||
, _ilIsSelected = False
|
||||
, _ilIsAttached = False
|
||||
-- , _ilIsAttached = False
|
||||
, _ilEquipSite = Nothing
|
||||
}
|
||||
return $ (invid,) $
|
||||
|
||||
@@ -60,7 +60,7 @@ crUpdateInvidLocations mo w invid itm =
|
||||
, _ilInvID = NInt invid
|
||||
, _ilIsRoot = Just (NInt invid) == mo ^? hiRootSelectedItem
|
||||
, _ilIsSelected = Just (Sel 0 invid) == w ^? hud . diSelection . _Just
|
||||
, _ilIsAttached = invid `IS.member` (mo ^. hiAttachedItems)
|
||||
-- , _ilIsAttached = invid `IS.member` (mo ^. hiAttachedItems)
|
||||
, _ilEquipSite = w ^? cWorld . lWorld . items . ix itid . itLocation . ilEquipSite . _Just
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ module Dodge.Item.BackgroundEffect (
|
||||
removeShieldWall,
|
||||
) where
|
||||
|
||||
import NewInt
|
||||
import Linear
|
||||
import Control.Lens
|
||||
import Dodge.Creature.Radius
|
||||
@@ -19,6 +20,8 @@ import Dodge.Wall.Create
|
||||
import Dodge.Wall.Delete
|
||||
import Dodge.Wall.Move
|
||||
import Geometry.Vector
|
||||
import qualified Data.IntSet as IS
|
||||
import Data.Maybe
|
||||
|
||||
cancelExamineInventory :: World -> World
|
||||
cancelExamineInventory = hud . subInventory %~ f
|
||||
@@ -44,11 +47,16 @@ rootAndAttNotEff ::
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
rootAndAttNotEff f g it
|
||||
rootAndAttNotEff f g it cr w
|
||||
| it ^? itLocation . ilIsRoot == Just True
|
||||
&& it ^? itLocation . ilIsAttached == Just True
|
||||
= f it
|
||||
| otherwise = g it
|
||||
&& isattached
|
||||
= f it cr w
|
||||
| otherwise = g it cr w
|
||||
where
|
||||
isattached = fromMaybe False $ do
|
||||
i <- it ^? itLocation . ilInvID . unNInt
|
||||
is <- w ^? hud . manObject . hiAttachedItems
|
||||
return $ i `IS.member` is
|
||||
|
||||
createShieldWall :: Item -> Creature -> World -> World
|
||||
createShieldWall it cr w = case it ^? itParams . flatShieldWlMIX . _Just of
|
||||
|
||||
Reference in New Issue
Block a user