Defunction-ify item modules, requires more cleanup

This commit is contained in:
2022-06-08 12:28:11 +01:00
parent d91a53f76c
commit bcbfd7d2fa
48 changed files with 762 additions and 740 deletions
+14 -24
View File
@@ -23,9 +23,7 @@ import Control.Lens
rewindGun :: Item
rewindGun = defaultGun
{ _itName = "REWINDER"
, _itType = REWINDER
, _itInvColor = cyan
{ _itInvColor = cyan
, _itConsumption = ChargeableAmmo
{ _wpMaxCharge = 250
, _wpCharge = 0
@@ -35,6 +33,7 @@ rewindGun = defaultGun
& lUse .~ useRewindGun
& eqEq . eqSite .~ GoesOnChest
}
& itType . iyBase .~ REWINDER
rewindEffect :: Item -> Creature -> World -> World
rewindEffect itm cr w
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take maxcharge . (w' : ))
@@ -65,14 +64,13 @@ useRewindGun _ _ w = case _rewindWorlds w of
-- needs to shift this item to the current inventory slot
shrinkGun :: Item
shrinkGun = defaultGun
{ _itName = "SHRINKER"
, _itType = SHRINKER
, _itConsumption = defaultAmmo
{ _itConsumption = defaultAmmo
, _itUse = defaultlUse {_lUse = hammerCheckL useShrinkGun}
& useHammer .~ upHammer
-- , _itFloorPict = shrinkGunPic
, _itAttachment = ItBool True
}
& itType . iyBase .~ SHRINKER
shrinkGunPic :: Item -> SPic
shrinkGunPic _ = noPic $ colorSH violet $ upperPrismPoly 5 $ square 5
@@ -92,9 +90,7 @@ useShrinkGun it cr w = if _itBool $ _itAttachment it
blinkGun :: Item
blinkGun = defaultGun
{ _itName = "BLINKER"
, _itType = BLINKER
, _itInvColor = cyan
{ _itInvColor = cyan
, _itConsumption = defaultAmmo
, _itUse = defaultlUse
& lUse .~ hammerCheckL (shootL $ const blinkAction)
@@ -102,42 +98,36 @@ blinkGun = defaultGun
& eqEq . eqSite .~ GoesOnWrist
-- , _itFloorPict = const . noPic . colorSH chartreuse $ upperPrismPoly 2 $ square 2
}
& itType . iyBase .~ BLINKER
unsafeBlinkGun :: Item
unsafeBlinkGun = blinkGun
& itName .~ "BLINKER-UNSAFE"
& itType .~ BLINKERUNSAFE
& itType . iyBase .~ BLINKERUNSAFE
& itUse . lUse .~ hammerCheckL (shootL $ const unsafeBlinkAction)
& itUse . eqEq . eqViewDist ?~ 400
effectGun :: String -> (Creature -> World -> World) -> Item
effectGun name eff = defaultGun
{ _itName = name ++ "Gun"
, _itUse = defaultrUse
{ _itUse = defaultrUse
& rUse .~ const eff
& useMods .~ [hammerCheckI]
}
effectGunCont :: String -> (Creature -> World -> World) -> Item
effectGunCont name eff = defaultGun
{ _itName = name ++ "Gun"
, _itUse = defaultrUse {_rUse = const eff}
}
& itType . iyBase .~ EFFGUN name
autoEffectGun :: String -> (Creature -> World -> World) -> Item
autoEffectGun name eff = defaultAutoGun
{ _itName = name ++ "Gun"
, _itUse = defaultrUse {_rUse = const eff}
autoEffectGun name eff = defaultGun
{ _itUse = defaultrUse {_rUse = const eff}
}
& itType . iyBase .~ AUTOEFFGUN name
forceFieldGun :: Item
forceFieldGun = defaultGun
{ _itName = "FORCEFIELDGUN"
, _itType = FORCEFIELDGUN
, _itConsumption = defaultAmmo & laType .~ ForceFieldAmmo forceField
{ _itConsumption = defaultAmmo & laType .~ ForceFieldAmmo forceField
, _itUse = ruseInstant useForceFieldGun (HasHammer HammerUp)
[ hammerCheckI , ammoCheckI , useAmmoAmount 1]
-- , _itFloorPict = \_ -> (,) emptySH $ onLayer FlItLayer $ polygon $ map toV2 [(-4,-4),(-4,4),(4,4),(4,0),(0,0),(0,-4)]
, _itTargeting = targetRBPress & tgDraw .~ targetDistanceDraw
, _itParams = ParamMID Nothing
}
& itType . iyBase .~ FORCEFIELDGUN
-- I believe because the targeting returns to nothing straight after you release
-- the rmb, it is possible for this to do nothing
-- TODO investigate more and fix