Add distance indicator for forcefield gun

This commit is contained in:
2022-06-07 16:01:08 +01:00
parent c8c299cfb5
commit 1c80447f9a
5 changed files with 54 additions and 28 deletions
+11 -8
View File
@@ -147,19 +147,22 @@ forceFieldGun = defaultGun
, _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
, _itTargeting = targetRBPress & tgDraw .~ targetDistanceDraw
, _itParams = ParamMID Nothing
}
-- 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
useForceFieldGun :: Item -> Creature -> World -> World
useForceFieldGun itm cr w = w
& walls %~ IM.insertWith (\_ x -> x) i forceField {_wlID = i}
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itParams . paramMID ?~ i
& moveWallIDUnsafe i wlline
useForceFieldGun itm cr w = fromMaybe w $ do
a <- _tgPos $ _itTargeting itm
let wlline = (a,mouseWorldPos w)
return $ w
& walls %~ IM.insertWith (\_ x -> x) i forceField {_wlID = i}
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itParams . paramMID ?~ i
& moveWallIDUnsafe i wlline
where
i = fromMaybe (IM.newKey (_walls w)) $ itm ^? itParams . paramMID . _Just
a = fromJust . _tgPos $ _itTargeting itm
wlline = (a,mouseWorldPos w)
-- grapGun = defaultGun
-- { _itName = "grapGun"