Allow for equipment items to set a minimum view distance

This commit is contained in:
2022-06-05 01:50:18 +01:00
parent 5e144b1cd5
commit 65fcea0f50
13 changed files with 76 additions and 61 deletions
+23 -23
View File
@@ -27,8 +27,8 @@ magShield = defaultEquipment
, _itID = Nothing
, _itAttachment = ItMInt Nothing
}
& itUse . eqUse .~ useMagShield
& itUse . eqSite .~ GoesOnWrist
& itUse . eqEq . eqUse .~ useMagShield
& itUse . eqEq . eqSite .~ GoesOnWrist
useMagShield :: Item -> Creature -> World -> World
useMagShield it cr w = w & magnets . at mgid ?~ themagnet
where
@@ -49,7 +49,7 @@ flameShield = defaultEquipment
, _itName = "FLAMESHIELD"
, _itEquipPict = \cr _ -> (,) emptySH $ setDepth 20 $ pictures [color cyan $ circle (_crRad cr+2)]
, _itID = Nothing
} & itUse . eqSite .~ GoesOnChest
} & itUse . eqEq . eqSite .~ GoesOnChest
{- | Slows you down, blocks forward projectiles. -}
frontArmour :: Item
frontArmour = defaultEquipment
@@ -61,7 +61,7 @@ frontArmour = defaultEquipment
])
, _itID = Nothing
}
& itUse . eqSite .~ GoesOnChest
& itUse . eqEq . eqSite .~ GoesOnChest
where
thecol = yellow -- (greyN 0.1)
@@ -72,32 +72,32 @@ wristArmour = defaultEquipment
, _itEquipPict = spicForWrist mempty
, _itID = Nothing
}
& itUse . eqSite .~ GoesOnWrist
& itUse . eqOnEquip .~ onEquipWristShield
& itUse . eqUse .~ setWristShieldPos
& itUse . eqOnRemove .~ onRemoveWristShield
& itUse . eqEq . eqSite .~ GoesOnWrist
& itUse . eqEq . eqOnEquip .~ onEquipWristShield
& itUse . eqEq . eqUse .~ setWristShieldPos
& itUse . eqEq . eqOnRemove .~ onRemoveWristShield
onEquipWristShield :: Item -> Creature -> World -> World
onEquipWristShield itm cr w = w
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itUse . eqParams .~ EquipID i
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itUse . eqEq . eqParams .~ EquipID i
& walls . at i ?~ (shieldWall (_crID cr)) {_wlDraw = True,_wlID = i}
& setWristShieldPos (itm & itUse . eqParams .~ EquipID i) cr
& setWristShieldPos (itm & itUse . eqEq . eqParams .~ EquipID i) cr
where
i = IM.newKey (_walls w)
onRemoveWristShield :: Item -> Creature -> World -> World
onRemoveWristShield itm cr w = w
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itUse . eqParams .~ NoEquipParams
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itUse . eqEq . eqParams .~ NoEquipParams
& deleteWallID i
where
i = _eparamID $ _eqParams $ _itUse itm
i = _eparamID $ _eqParams $ _eqEq $ _itUse itm
setWristShieldPos :: Item -> Creature -> World -> World
setWristShieldPos itm cr w = w
& moveWallIDUnsafe i wlline
-- & testString .~ (\w' -> [shortShow $ _wlLine (_walls w' IM.! i)])
-- & tempLightSources .:~ tlsTimeRadColPos 1 200 0.7 (fst wlline `v2z` 40)
where
i = _eparamID $ _eqParams $ _itUse itm
i = _eparamID $ _eqParams $ _eqEq $ _itUse itm
wlline = (f (V3 (-10) 7 0), f (V3 10 7 0))
invid = fromJust (_itInvPos itm)
--wlline = (V2 10 0, V2 (-10) 100)
@@ -222,7 +222,7 @@ jetPack = defaultEquipment
$ pictures [color yellow $ polygon $ rectNSEW 5 (-5) (-3) (-11) ]
, _itEffect = NoItEffect
, _itID = Nothing
} & itUse . eqSite .~ GoesOnBack
} & itUse . eqEq . eqSite .~ GoesOnBack
brainHat :: Item
brainHat = defaultEquipment
@@ -232,7 +232,7 @@ brainHat = defaultEquipment
, _itEffect = NoItEffect
, _itID = Nothing
}
& itUse . eqSite .~ GoesOnHead
& itUse . eqEq . eqSite .~ GoesOnHead
headLamp1 :: Item
headLamp1 = defaultEquipment
@@ -246,8 +246,8 @@ headLamp1 = defaultEquipment
, _itEffect = NoItEffect
, _itID = Nothing
}
& itUse . eqUse .~ createHeadLamp
& itUse . eqSite .~ GoesOnHead
& itUse . eqEq . eqUse .~ createHeadLamp
& itUse . eqEq . eqSite .~ GoesOnHead
headLamp :: Item
headLamp = defaultEquipment
{ _itType = HEADLAMP
@@ -256,8 +256,8 @@ headLamp = defaultEquipment
, _itEffect = NoItEffect
, _itID = Nothing
}
& itUse . eqUse .~ createHeadLamp
& itUse . eqSite .~ GoesOnHead
& itUse . eqEq . eqUse .~ createHeadLamp
& itUse . eqEq . eqSite .~ GoesOnHead
headLampShape :: Shape
headLampShape = colorSH yellow $
@@ -278,7 +278,7 @@ powerLegs = defaultEquipment
, _itEffect = NoItEffect
, _itID = Nothing
}
& itUse . eqSite .~ GoesOnLegs
& itUse . eqEq . eqSite .~ GoesOnLegs
speedLegs :: Item
speedLegs = powerLegs
{ _itType = SPEEDLEGS
@@ -297,9 +297,9 @@ wristInvisibility = defaultEquipment
, _itEquipPict = shapeForWrist (colorSH chartreuse $ upperPrismPoly 3 $ rectWH 2 2)
, _itID = Nothing
}
& itUse . eqSite .~ GoesOnWrist
& itUse . eqOnEquip .~ overCID (crCamouflage .~ Invisible)
& itUse . eqOnRemove .~ overCID (crCamouflage .~ FullyVisible)
& itUse . eqEq . eqSite .~ GoesOnWrist
& itUse . eqEq . eqOnEquip .~ overCID (crCamouflage .~ Invisible)
& itUse . eqEq . eqOnRemove .~ overCID (crCamouflage .~ FullyVisible)
overCID :: (Creature -> Creature) -> Item -> Creature -> World -> World
overCID f _ cr = creatures . ix (_crID cr) %~ f