Add distance indicator for forcefield gun
This commit is contained in:
@@ -11,6 +11,7 @@ module Dodge.Item.Weapon.ExtraEffect
|
||||
, targetRBCreature
|
||||
, targetCursor
|
||||
, targetLaser
|
||||
, targetDistanceDraw
|
||||
-- , rbSetTarget
|
||||
) where
|
||||
import Dodge.Data
|
||||
@@ -28,6 +29,7 @@ import Geometry.Data
|
||||
import LensHelp
|
||||
import qualified FoldlHelp as L
|
||||
import Sound.Data
|
||||
import ShortShow
|
||||
|
||||
--import Data.Bifunctor
|
||||
import Data.Maybe
|
||||
@@ -75,16 +77,35 @@ targetCursor = defaultTargeting
|
||||
& tgUpdate .~ targetUpdateWith targetCursorUpdate
|
||||
& tgDraw .~ targetSimpleDraw
|
||||
|
||||
targetDraw :: (Item -> Picture) -> Int -> Item -> Creature -> Configuration -> World -> Picture
|
||||
targetDraw f _ it _ cfig w = fromMaybe mempty $ do
|
||||
targetDraw :: (Item -> Picture) -> Item -> Creature -> Configuration -> World -> Picture
|
||||
targetDraw f it _ cfig w = fromMaybe mempty $ do
|
||||
p <- it ^? itTargeting . tgPos . _Just
|
||||
return $ winScale cfig
|
||||
$ setLayer FixedCoordLayer
|
||||
$ color white
|
||||
$ uncurryV translate (worldPosToScreen w p)
|
||||
$ f it
|
||||
targetSimpleDraw :: Int -> Item -> Creature -> Configuration -> World -> Picture
|
||||
targetSimpleDraw :: Item -> Creature -> Configuration -> World -> Picture
|
||||
targetSimpleDraw = targetDraw $ const activeTargetCursorPic
|
||||
|
||||
targetDistanceDraw :: Item -> Creature -> Configuration -> World -> Picture
|
||||
targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do
|
||||
p <- itm ^? itTargeting . tgPos . _Just
|
||||
let p1 = worldPosToScreen w p
|
||||
mwp = mouseWorldPos w
|
||||
p2 = worldPosToScreen w mwp
|
||||
return $ winScale cfig
|
||||
$ setLayer FixedCoordLayer
|
||||
$ color white
|
||||
$ line [p1, p2]
|
||||
<> translate (20) (f p1 p2) (uncurryV translate (0.5 *.* (p1 +.+ p2)) . scale 0.1 0.1 $ text $ shortShow $ dist p mwp)
|
||||
where
|
||||
f (V2 x y) (V2 x' y')
|
||||
| y > y' && x > x' = max (-10) (x'-x)
|
||||
| y > y' && x < x' = min 10 (x'-x)
|
||||
| x > x' = min 10 (x-x')
|
||||
| otherwise = max (-10) (x-x')
|
||||
|
||||
targetRBCreatureUp :: Item -> Creature -> World -> Targeting -> (World, Targeting)
|
||||
targetRBCreatureUp it cr w t
|
||||
| not $ _itIsHeld it = (w, t
|
||||
@@ -114,7 +135,7 @@ targetRBCreatureUp it cr w t
|
||||
cpos <- w ^? creatures . ix cid . crPos
|
||||
Just $ hasLOS cpos (_crPos cr) w
|
||||
|
||||
targetRBCreatureDraw :: Int -> Item -> Creature -> Configuration -> World -> Picture
|
||||
targetRBCreatureDraw :: Item -> Creature -> Configuration -> World -> Picture
|
||||
targetRBCreatureDraw = targetDraw thepic
|
||||
where
|
||||
thepic it | _tgActive $ _itTargeting it = activeTargetCursorPic
|
||||
|
||||
Reference in New Issue
Block a user