Move towards implementing wrist shields
This commit is contained in:
+37
-11
@@ -27,8 +27,8 @@ magShield = defaultEquipment
|
||||
}
|
||||
& itUse . eqUse .~ useMagShield
|
||||
& itUse . eqSite .~ GoesOnWrist
|
||||
useMagShield :: Creature -> Int -> World -> World
|
||||
useMagShield cr invid w = w & magnets . at mgid ?~ themagnet
|
||||
useMagShield :: Item -> Creature -> World -> World
|
||||
useMagShield it cr w = w & magnets . at mgid ?~ themagnet
|
||||
where
|
||||
themagnet = Magnet
|
||||
{_mgID = mgid
|
||||
@@ -39,7 +39,7 @@ useMagShield cr invid w = w & magnets . at mgid ?~ themagnet
|
||||
mgid = case it ^? itAttachment . itMInt . _Just of
|
||||
Just mgid' -> mgid'
|
||||
Nothing -> IM.newKey $ _magnets w
|
||||
it = _crInv cr IM.! invid
|
||||
-- it = _crInv cr IM.! invid
|
||||
|
||||
flameShield :: Item
|
||||
flameShield = defaultEquipment
|
||||
@@ -68,16 +68,42 @@ wristArmour :: Item
|
||||
wristArmour = defaultEquipment
|
||||
{ _itType = WRISTARMOUR
|
||||
, _itName = "WRISTARMOUR"
|
||||
, _itEquipPict = spicForWrist (emptySH , setDepth 20 $ pictures
|
||||
[color thecol $ thickArc 0 (pi/2) 10 5
|
||||
,color thecol $ thickArc (3*pi/2) (2*pi) 10 5
|
||||
])
|
||||
, _itEquipPict = spicForWrist mempty
|
||||
, _itEffect = NoItEffect
|
||||
, _itID = Nothing
|
||||
}
|
||||
& itUse . eqSite .~ GoesOnWrist
|
||||
& itUse . eqOnEquip .~ onEquipWristShield
|
||||
& itUse . eqUse .~ setWristShieldPos
|
||||
& itUse . 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
|
||||
& walls . at i ?~ (shieldWall (_crID cr)) {_wlDraw = True}
|
||||
& setWristShieldPos (itm & itUse . eqParams .~ EquipID i) cr
|
||||
where
|
||||
thecol = yellow -- (greyN 0.1)
|
||||
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
|
||||
-- & walls . at i .~ Nothing
|
||||
where
|
||||
i = _eparamID $ _eqParams $ _itUse itm
|
||||
setWristShieldPos :: Item -> Creature -> World -> World
|
||||
setWristShieldPos itm cr w = w
|
||||
& moveWallIDUnsafe i wlline
|
||||
-- & tempLightSources .:~ tlsTimeRadColPos 1 200 0.7 (fst wlline `v2z` 40)
|
||||
where
|
||||
i = _eparamID $ _eqParams $ _itUse itm
|
||||
wlline = (f (V3 (-10) 7 0), f (V3 10 7 0))
|
||||
invid = fromJust (_itInvPos itm)
|
||||
--wlline = (V2 10 0, V2 (-10) 100)
|
||||
handtrans = case cr ^? crInvEquipped . ix invid of
|
||||
Just OnLeftWrist -> translatePointToLeftHand
|
||||
_ -> translatePointToRightHand
|
||||
f = (+.+ _crPos cr) . stripZ . rotate3 (_crDir cr) . handtrans cr
|
||||
|
||||
|
||||
spicForWrist :: SPic -> Creature -> Item -> SPic
|
||||
spicForWrist = pictureOnEquip . translateSP (V3 0 4 (-4))
|
||||
@@ -89,7 +115,7 @@ pictureOnEquip sp cr itm = fromMaybe mempty $ do
|
||||
equipPosition :: EquipPosition -> Creature -> SPic -> SPic
|
||||
equipPosition epos cr sh = case epos of
|
||||
OnLeftWrist -> translateToLeftHand cr sh
|
||||
OnRightWrist -> translateToRightHand cr $ mirrorSPxz sh
|
||||
OnRightWrist -> translateToRightHand cr sh
|
||||
OnLegs -> translateToLeftLeg cr sh <>
|
||||
translateToRightLeg cr (mirrorSPxz sh)
|
||||
OnHead -> translateToHead cr sh
|
||||
@@ -253,8 +279,8 @@ headLampShape = colorSH yellow $
|
||||
<> translateSH (V3 5 (-2) 4) (upperPrismPoly 4 $ rectWH 4 1)
|
||||
<> translateSH (V3 5 (-2) 0) (upperPrismPoly 4 $ rectWH 4 1)
|
||||
|
||||
createHeadLamp :: Creature -> Int -> World -> World
|
||||
createHeadLamp cr _ = tempLightSources .:~ tlsTimeRadColPos 1 200 0.7
|
||||
createHeadLamp :: Item -> Creature -> World -> World
|
||||
createHeadLamp _ cr = tempLightSources .:~ tlsTimeRadColPos 1 200 0.7
|
||||
((_crPos cr `v2z` 0) +.+.+ rotate3 (_crDir cr) (translatePointToHead cr (V3 5 0 3)))
|
||||
|
||||
powerLegs :: Item
|
||||
|
||||
Reference in New Issue
Block a user