Commit before moving targeting

This commit is contained in:
2023-01-05 09:58:41 +00:00
parent ac8afe513b
commit c48a553967
14 changed files with 50 additions and 17 deletions
+25
View File
@@ -1,5 +1,7 @@
module Dodge.Euse where
import Control.Monad
import Data.Maybe
import Dodge.LightSource
import Dodge.Item.HeldOffset
import Dodge.Wall.Create
@@ -29,6 +31,29 @@ useE eo = case eo of
ECamouflage vis -> overCID (crCamouflage .~ vis)
EonWristShield -> onEquipWristShield
EoffWristShield -> onRemoveWristShield
EFuelSource 0 _ -> const . const id
EFuelSource {} -> trySiphonFuel
trySiphonFuel :: Item -> Creature -> World -> World
trySiphonFuel itm cr w = fromMaybe w $ do
eix <- itm ^? itLocation . ipInvID
hix <- cr ^? crInvSel . iselPos
guard (cr ^? crInvSel . iselAction == Just NoInvSelAction)
la <- cr ^? crInv . ix hix . itUse . heldConsumption
atype <- la ^? laAmmoType
guard (isGas atype)
amax <- la ^? laMax
acur <- la ^? laLoaded
guard (amax > acur)
return $ w & cWorld . lWorld . creatures . ix (_crID cr) . crInv %~
( (ix hix . itUse . heldConsumption . laLoaded +~ 1)
. (ix eix . itUse . equipEffect . eeUse . euseFuelAmount -~ 1)
)
isGas :: AmmoType -> Bool
isGas a = case a of
GasAmmo {} -> True
_ -> False
useMagShield :: Item -> Creature -> World -> World
useMagShield it cr w = w & cWorld . lWorld . magnets . at mgid ?~ themagnet