Tweak inventory manipulation

This commit is contained in:
2026-04-06 18:07:35 +01:00
parent 262463c52d
commit 9d7c9f1db2
5 changed files with 164 additions and 156 deletions
+2 -2
View File
@@ -7,8 +7,8 @@ import Control.Lens
crMvType :: Creature -> CrMvType
crMvType cr = case _crType cr of
Avatar {} -> MvWalking 1.5
ChaseCrit {} -> defaultChaseMvType
HoverCrit {} -> defaultChaseMvType & mvSpeed .~ 0.15
ChaseCrit {} -> defaultChaseMvType & mvSpeed .~ 1.8
HoverCrit {} -> defaultChaseMvType & mvSpeed .~ 0.16
SwarmCrit -> defaultChaseMvType
AutoCrit -> defaultAimMvType
BarrelCrit {} -> defaultAimMvType
+2 -2
View File
@@ -1,10 +1,10 @@
module Dodge.Placement.Instance.Creature where
import Dodge.Creature.ArmourChase
--import Dodge.Creature.ArmourChase
import Dodge.Creature.ChaseCrit
import Dodge.Data.GenWorld
import RandomHelp
randC1 :: PSType
randC1 = RandPS $ takeOne $ map PutCrit $ armourChaseCrit : replicate 50 hoverCrit
randC1 = RandPS $ takeOne $ map PutCrit [hoverCrit,chaseCrit]
--randC1 = RandPS $ takeOne $ map PutCrit [hoverCrit]
+3 -4
View File
@@ -56,8 +56,9 @@ tutAnoTree = do
foldMTRS
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
, corDoor
, loadAmmoTut
, corDoor
, chasmSpitTerminal
-- , loadAmmoTut
--b , corDoor
--b , tToBTree "slowCrush" . return . cleatOnward <$> pushCaverns
--b , corDoor
@@ -449,9 +450,7 @@ loadAmmoTut = do
return $
tToBTree "loadAmmoTest" $
treePost
[ croom
, door
, amrm & rmPmnts .:~ sps (PS 50 0) (PutFlIt (drumMag & itConsumables ?~ 90))
[ amrm & rmPmnts .:~ sps (PS 50 0) (PutFlIt (drumMag & itConsumables ?~ 90))
, triggerDoorRoom i
, wprm & rmPmnts .:~ sps (PS 50 0) (PutFlIt burstRifle)
, triggerDoorRoom j
+15 -5
View File
@@ -144,7 +144,7 @@ doDrag cfig n k mmouseover w = fromMaybe w $ do
guard (n /= 0)
ss <- w ^? hud . diSections . ix k . ssItems
x <- mmouseover
is <- w ^? hud . diSelection . _Just . slSet
is <- selectionSet w
return $
if concurrentIS is
then shiftInvItems cfig n k x is ss w
@@ -154,15 +154,24 @@ tryDropSelected :: Maybe (Int, Int) -> World -> Maybe World
tryDropSelected mpos w = do
guard $ maybe True (\(i, _) -> i == 3) mpos
cr <- w ^? cWorld . lWorld . creatures . ix 0
Sel 0 _ xs <- w ^? hud . diSelection . _Just
return . foldl' (flip $ dropItem cr) w . IS.toDescList $ xs
0 <- w ^? hud . diSelection . _Just . slSec
xs <- selectionSet w
return
. (hud . diSelection ?~ Sel 3 0 (IS.fromDistinctAscList [0..IS.size xs - 1]))
. foldl' (flip $ dropItem cr) w . IS.toDescList $ xs
selectionSet :: World -> Maybe IS.IntSet
selectionSet w = case w ^? hud . diSelection . _Just . slSet of
Just is' | not $ IS.null is' -> Just is'
_ -> IS.singleton <$> w ^? hud . diSelection . _Just . slInt
tryPickupSelected :: Int -> Maybe (Int, Int) -> World -> Maybe World
tryPickupSelected k mpos w = do
guard $ k == 3
guard $ maybe True (\(i, _) -> i == 0 || i == 1) mpos
cr <- w ^? cWorld . lWorld . creatures . ix 0
xs <- w ^? hud . diSelection . _Just . slSet
xs <- selectionSet w
let nfreeslots = crNumFreeSlots (w ^. cWorld . lWorld . items) cr
itmstopickup = mapMaybe g $ IS.toList xs
slotsneeded = alaf Sum foldMap itInvHeight itmstopickup
@@ -299,7 +308,8 @@ endCombineRegex w = ssSetCursor (ssLookupDown 0 j) sss
startDrag :: (Int, Int) -> World -> World
startDrag (a, b) w = setcontext $ case w ^? hud . diSelection . _Just of
Just (Sel i _ xs) | i == a && b `IS.member` xs -> w
_ -> invSetSelection (Sel a b (IS.singleton b)) w
-- _ -> invSetSelection (Sel a b (IS.singleton b)) w
_ -> invSetSelection (Sel a b mempty) w
where
setcontext = input . mouseContext .~ OverInvDrag a (Just (a, b))