Continue inventory tweak

This commit is contained in:
2023-02-16 17:07:59 +00:00
parent 934dd64704
commit 4afc216b25
28 changed files with 106 additions and 94 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ showAutoRechargeProgress lc = case lc of
ChargeableAmmo{} -> show (_wpCharge lc)
showReloadProgress :: Creature -> HeldConsumption -> String
showReloadProgress cr ic = case cr ^? crManipulation . isel . iselAction of
showReloadProgress cr ic = case cr ^? crManipulation . manObject . inInventory . iselAction of
Just (ReloadAction i la) -> show i ++ showLoadActionType la (_laLoaded ic)
_ -> case ic ^? laProgress . _Just . ix 0 of
Nothing -> show $ _laLoaded ic
+4 -4
View File
@@ -137,7 +137,7 @@ shootLaser it cr = cWorld . lWorld . lasers .:~ lasRayAt (_lasColor $ _itParams
pos = _crPos cr
dir = _crDir cr
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
dam = _lasDamage $ _itParams it
-- this has the feel of a left click item
@@ -153,7 +153,7 @@ circleLaser it cr w
pos = _crPos cr +.+ rotateV dir (V2 0 (max 70 $ dist cpos mwp))
dir = fromIntegral (_lasCycle (_itParams it)) * pi / 1000
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
dam = _lasDamage $ _itParams it
shootDualLaser :: Item -> Creature -> World -> World
@@ -176,7 +176,7 @@ shootDualLaser it cr w =
dirl = argV $ mwp' -.- posl
dirr = argV $ mwp' -.- posr
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
dam = _lasDamage $ _itParams it
basicBeamAt :: Int -> World -> Color -> Int -> Float -> Point2 -> Float -> Beam
@@ -211,7 +211,7 @@ aTractorBeam _ cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos
dir = _crDir cr
outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
power = _attractionPower . _itParams $ _crInv cr IM.! itRef
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
tractorBeamAt pos outpos dir power =
+9 -9
View File
@@ -191,7 +191,7 @@ rateIncAB exeffFirst exeffCont eff item cr w
fastRate = _rateMinMax . _heldDelay $ _itUse item
startRate = _rateMaxMax . _heldDelay $ _itUse item
cid = _crID cr
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
pointItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
currentRate = _rateMax (_heldDelay (_itUse item))
repeatFire = crWeaponReady cr && _rateTime (_heldDelay (_itUse item)) == 1
@@ -215,7 +215,7 @@ withWarmUp soundID f item cr w
& f item cr
where
cid = _crID cr
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
curWarmUp = _warmTime . _heldDelay $ _itUse item
maxWarmUp = _warmMax . _heldDelay $ _itUse item
@@ -343,7 +343,7 @@ useAllAmmo eff item cr =
eff item cr
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded .~ 0)
where
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
useAmmoUpTo :: Int -> ChainEffect
useAmmoUpTo amAmount eff item cr =
@@ -352,14 +352,14 @@ useAmmoUpTo amAmount eff item cr =
%~ (max 0 . subtract amAmount)
)
where
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
useAmmoAmount :: Int -> ChainEffect
useAmmoAmount amAmount eff item cr =
eff item cr
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded -~ amAmount)
where
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
{- |
Applies a world effect after an item use cooldown check.
@@ -371,7 +371,7 @@ useTimeCheck f item cr w = case item ^? itUse . heldDelay . rateTime of
where
cid = _crID cr
setUseTime = cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTime +~ userate
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
userate = fromMaybe 0 $ item ^? itUse . heldDelay . rateMax
-- | Applies a world effect after a hammer position check.
@@ -396,7 +396,7 @@ ammoUseCheck f item cr w
| otherwise = w
where
cid = _crID cr
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
fireCondition =
crWeaponReady cr
@@ -453,12 +453,12 @@ withItem g f it = g it f it
withItemUpdate' :: (Item -> Item) -> ChainEffect
withItemUpdate' up f it cr = f (up it) cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
where
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
withItemUpdate :: (Item -> Item) -> (Item -> ChainEffect) -> ChainEffect
withItemUpdate up g f it cr = g it f it cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
where
itRef = cr ^?! crManipulation . isel . ispItem -- unsafe!! TODO change
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
withTempLight time rad col eff item cr =