Partially working change to selected items

This commit is contained in:
2023-02-07 12:07:13 +00:00
parent 5f7d662454
commit c354949ca9
27 changed files with 386 additions and 288 deletions
+8 -4
View File
@@ -136,7 +136,8 @@ shootLaser it cr = cWorld . lWorld . lasers .:~ lasRayAt (_lasColor $ _itParams
where
pos = _crPos cr
dir = _crDir cr
phasev = _phaseV . _itParams $ _crInv cr IM.! crSel cr
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
dam = _lasDamage $ _itParams it
-- this has the feel of a left click item
@@ -151,7 +152,8 @@ circleLaser it cr w
mwp = mouseWorldPos (w ^. input) (w ^. cWorld . camPos)
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.! crSel cr
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
dam = _lasDamage $ _itParams it
shootDualLaser :: Item -> Creature -> World -> World
@@ -173,7 +175,8 @@ shootDualLaser it cr w =
| otherwise = mwp
dirl = argV $ mwp' -.- posl
dirr = argV $ mwp' -.- posr
phasev = _phaseV . _itParams $ _crInv cr IM.! crSel cr
phasev = _phaseV . _itParams $ _crInv cr IM.! itRef
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
dam = _lasDamage $ _itParams it
basicBeamAt :: Int -> World -> Color -> Int -> Float -> Point2 -> Float -> Beam
@@ -207,7 +210,8 @@ aTractorBeam _ cr w = w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
dir = _crDir cr
outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
power = _attractionPower . _itParams $ _crInv cr IM.! crSel cr
power = _attractionPower . _itParams $ _crInv cr IM.! itRef
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
tractorBeamAt :: Point2 -> Point2 -> Float -> Point2 -> TractorBeam
tractorBeamAt pos outpos dir power =
+20 -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 = crSel cr
itRef = cr ^?! crInvSel . isel . 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 = crSel cr
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
curWarmUp = _warmTime . _heldDelay $ _itUse item
maxWarmUp = _warmMax . _heldDelay $ _itUse item
@@ -341,19 +341,25 @@ withSidePushAfterI maxSide eff item cr w =
useAllAmmo :: ChainEffect
useAllAmmo eff item cr =
eff item cr
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itUse . heldConsumption . laLoaded .~ 0)
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded .~ 0)
where
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
useAmmoUpTo :: Int -> ChainEffect
useAmmoUpTo amAmount eff item cr =
eff item cr
. ( cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itUse . heldConsumption . laLoaded
. ( cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded
%~ (max 0 . subtract amAmount)
)
where
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
useAmmoAmount :: Int -> ChainEffect
useAmmoAmount amAmount eff item cr =
eff item cr
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) . itUse . heldConsumption . laLoaded -~ amAmount)
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded -~ amAmount)
where
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
{- |
Applies a world effect after an item use cooldown check.
@@ -364,7 +370,8 @@ useTimeCheck f item cr w = case item ^? itUse . heldDelay . rateTime of
_ -> w
where
cid = _crID cr
setUseTime = cWorld . lWorld . creatures . ix cid . crInv . ix (crSel cr) . itUse . heldDelay . rateTime +~ userate
setUseTime = cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTime +~ userate
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
userate = fromMaybe 0 $ item ^? itUse . heldDelay . rateMax
-- | Applies a world effect after a hammer position check.
@@ -389,7 +396,7 @@ ammoUseCheck f item cr w
| otherwise = w
where
cid = _crID cr
itRef = crSel cr
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
fireCondition =
crWeaponReady cr
@@ -444,10 +451,14 @@ withItem g f it = g it f it
-- not ideal
withItemUpdate' :: (Item -> Item) -> ChainEffect
withItemUpdate' up f it cr = f (up it) cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (crSel cr) %~ up)
withItemUpdate' up f it cr = f (up it) cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
where
itRef = cr ^?! crInvSel . isel . 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 (crSel cr) %~ up)
withItemUpdate up g f it cr = g it f it cr . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef %~ up)
where
itRef = cr ^?! crInvSel . isel . ispItem -- unsafe!! TODO change
withTempLight :: Int -> Float -> V3 Float -> ChainEffect
withTempLight time rad col eff item cr =