Start keeping track of item equip status internally (partially done)

This commit is contained in:
2024-12-19 00:55:14 +00:00
parent 5600b29714
commit 331a9a2f9b
17 changed files with 209 additions and 202 deletions
+4 -8
View File
@@ -27,8 +27,7 @@ megaTinMag x =
tinMag :: Item
tinMag =
defaultHeldItem & itType .~ AMMOMAG TINMAG
& itUse
.~ UseAmmoMag
& itUse .~ UseNothing
& itConsumables .~ AmmoMag
{ _magParams = BulletParams defaultBullet
, _magType = BulletAmmo
@@ -68,8 +67,7 @@ megaShellMag =
shellMag :: Item
shellMag =
defaultHeldItem & itType .~ AMMOMAG SHELLMAG
& itUse
.~ UseAmmoMag
& itUse .~ UseNothing
& itConsumables
.~ AmmoMag
{ _magParams =
@@ -99,8 +97,7 @@ smallBattery =
battery :: Item
battery =
defaultHeldItem & itType .~ AMMOMAG BATTERY
& itUse
.~ UseAmmoMag
& itUse .~ UseNothing
& itConsumables
.~ AmmoMag
{ _magParams = BulletParams defaultBullet
@@ -115,8 +112,7 @@ battery =
chemFuelPouch :: Item
chemFuelPouch =
defaultHeldItem & itType .~ AMMOMAG CHEMFUELPOUCH
& itUse
.~ UseAmmoMag
& itUse .~ UseNothing
& itConsumables
.~ AmmoMag
{ _magParams = GasParams ChemFuel
+5 -4
View File
@@ -84,19 +84,20 @@ itemNumberDisplay cr ci = case (ci ^. _2, itm ^?! itUse, itm ^. itType) of
(_,_,EQUIP WRIST_ECG) -> [displayPulse $ cr ^?! crType . avatarPulse . pulseProgress]
(WeaponTargetingSF,_,_)
-> [maybe "" (const "!TARG!") (itm ^? itTargeting . itTgPos . _Just)]
_ | hasammo -> [maybe "" shortShow
$ itm ^? itConsumables . magLoadStatus . iaLoaded]
(_,UseHeld{},_) -> []
(_,UseHotkey{_leftConsumption=lc},_) -> [showAutoRechargeProgress lc]
(_,UseEquip{},_) -> showEquipmentNumber cr itm
(_,UseCraft,_) -> []
(_,UseNothing,_) -> []
(_,UseConsume {},_) -> []
(_,UseAttach (APInt i),_) -> [show i]
(_,UseAttach {},_) -> []
(_,UseAmmoMag {},_) -> [maybe "" shortShow
$ itm ^? itConsumables . magLoadStatus . iaLoaded]
(_,UseScope OpticScope {_opticZoom = x},_) -> [shortShow x]
(_,UseBulletMod {},_) -> mempty
where
itm = ci ^. _1
hasammo = isJust $ itm ^? itConsumables . magLoadStatus . iaLoaded
displayPulse :: Int -> String
displayPulse 0 = "*****"
@@ -106,7 +107,7 @@ displayPulse x = take 5 $ drop y "----^-----"
showEquipmentNumber :: Creature -> Item -> [String]
showEquipmentNumber _ itm = case _eeUse ee of
EFuelSource x _ -> [show x]
-- EFuelSource x _ -> [show x]
EAmmoSource{_euseAmmoAmount = x} -> [show x]--showAmmoSource cr itm
EBatterySource{_euseBatteryAmount = x} -> [show x]
_ -> [""]
+11 -1
View File
@@ -67,8 +67,18 @@ fuelPack =
defaultEquipment
& itUse . uequipEffect . eeSite .~ GoesOnBack
& itUse . uequipEffect . eeAttachPos .~ V3 (-9) 0 10
& itUse . uequipEffect . eeUse .~ EFuelSource 10000 10000
-- & itUse . uequipEffect . eeUse .~ EFuelSource 10000 10000
& itType .~ EQUIP FUELPACK
& itConsumables
.~ AmmoMag
{ _magParams = GasParams ChemFuel
, _magType = GasAmmo
, _magLoadStatus =
ReloadStatus
{ _iaMax = 100000
, _iaLoaded = 100000
}
}
bulletBeltPack :: Item
bulletBeltPack =
+2 -2
View File
@@ -25,13 +25,13 @@ pointerToItemLocation _ = const pure
pointerYourSelectedItem :: Applicative a => (Item -> a Item) -> World -> a World
pointerYourSelectedItem f w = fromMaybe (pure w) $ do
itinvid <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem
Just $ pointerToItemLocation (InInv 0 itinvid True True True) f w
Just $ pointerToItemLocation (InInv 0 itinvid True True True Nothing) f w
-- note the ilIsRoot/Selected/Attached booleans are irrelevant
pointerYourRootItem :: Applicative a => (Item -> a Item) -> World -> a World
pointerYourRootItem f w = fromMaybe (pure w) $ do
itinvid <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imRootSelectedItem
Just $ pointerToItemLocation (InInv 0 itinvid True True True) f w
Just $ pointerToItemLocation (InInv 0 itinvid True True True Nothing) f w
pointerToItem ::
Applicative f =>
+1
View File
@@ -50,6 +50,7 @@ initCrItemLocation cr invid w it = (w & itemLocations . at locid ?~ loc
, _ilIsRoot = False
, _ilIsSelected = False
, _ilIsAttached = False
, _ilEquipPosition = Nothing
}
+1 -1
View File
@@ -22,7 +22,7 @@ zoomScope = defaultHeldItem
targetingScope :: TargetingType -> Item
targetingScope tt = defaultHeldItem
& itType .~ TARGETING tt
& itUse .~ UseCraft
& itUse .~ UseNothing
& itTargeting .~ ItTargeting
{ _itTgPos = Nothing
, _itTgID = Nothing