Implement targeting launcher shells using separate item

This commit is contained in:
2024-09-29 16:24:26 +01:00
parent 7d72fa3c5d
commit 88c3e02459
36 changed files with 747 additions and 610 deletions
+43 -38
View File
@@ -2,16 +2,16 @@ module Dodge.Targeting.Draw (
drawTargeting,
) where
import Data.Maybe
import Dodge.Base
--import Data.Maybe
--import Dodge.Base
import Dodge.Data.Universe
import Geometry.Data
import Geometry.Vector
import LensHelp
--import Geometry.Vector
--import LensHelp
import Picture
import ShortShow
--import ShortShow
drawTargeting :: TargetType -> Creature -> Configuration -> World -> Picture
drawTargeting :: TargetingType -> Creature -> Configuration -> World -> Picture
drawTargeting td = case td of
TargetRBCreature -> targetRBCreatureDraw
TargetRBLine -> targetDistanceDraw
@@ -23,48 +23,53 @@ targetSimpleDraw :: Creature -> Configuration -> World -> Picture
targetSimpleDraw = targetDraw activeTargetCursorPic
targetDistanceDraw :: Creature -> Configuration -> World -> Picture
targetDistanceDraw cr _ w = fromMaybe mempty $ do
p <- cr ^? crTargeting . ctPos . _Just
let p1 = worldPosToScreen cam p
mwp = mouseWorldPos (w ^. input) (w ^. wCam)
p2 = worldPosToScreen cam mwp
thecol = if dist p mwp > 100 then red else white
return .
setLayer FixedCoordLayer $
color thecol $
line [p1, p2]
<> transMidLine p1 p2 (scale 0.1 0.1 . text . shortShow $ dist p mwp)
where
cam = w ^. wCam
targetDistanceDraw _ _ _ = mempty
--targetDistanceDraw cr _ w = mempty
-- fromMaybe mempty $ do
-- p <- cr ^? crTargeting . ctPos . _Just
-- let p1 = worldPosToScreen cam p
-- mwp = mouseWorldPos (w ^. input) (w ^. wCam)
-- p2 = worldPosToScreen cam mwp
-- thecol = if dist p mwp > 100 then red else white
-- return .
-- setLayer FixedCoordLayer $
-- color thecol $
-- line [p1, p2]
-- <> transMidLine p1 p2 (scale 0.1 0.1 . text . shortShow $ dist p mwp)
-- where
-- cam = w ^. wCam
targetDraw :: Picture -> Creature -> Configuration -> World -> Picture
targetDraw f cr _ _ = fromMaybe mempty $ do
p <- cr ^? crTargeting . ctPos . _Just
return .
setLayer DebugLayer $
color white $
uncurryV translate p f
targetDraw _ _ _ _ = mempty
--targetDraw f cr _ _ = mempty
-- fromMaybe mempty $ do
-- p <- cr ^? crTargeting . ctPos . _Just
-- return .
-- setLayer DebugLayer $
-- color white $
-- uncurryV translate p f
activeTargetCursorPic :: Picture
activeTargetCursorPic =
fold
[rotate a $ line [V2 15 0, V2 10 0] <> targCorner | a <- [0, 0.5 * pi, pi, 1.5 * pi]]
transMidLine :: Point2 -> Point2 -> Picture -> Picture
transMidLine p1 p2 = translate 20 (f p1 p2) . uncurryV translate (0.5 *.* (p1 +.+ p2))
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')
--transMidLine :: Point2 -> Point2 -> Picture -> Picture
--transMidLine p1 p2 = translate 20 (f p1 p2) . uncurryV translate (0.5 *.* (p1 +.+ p2))
-- 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')
targetRBCreatureDraw :: Creature -> Configuration -> World -> Picture
targetRBCreatureDraw cr = targetDraw thepic cr
where
thepic
| _ctActive $ _crTargeting cr = activeTargetCursorPic
| otherwise = targetCursorPic
targetRBCreatureDraw cr = targetDraw targetCursorPic cr
--targetRBCreatureDraw cr = targetDraw thepic cr
-- where
-- thepic
-- | _ctActive $ _crTargeting cr = activeTargetCursorPic
-- | otherwise = targetCursorPic
targCorner :: Picture
targCorner = line [V2 (x - y) x, V2 x x, V2 x (x - y)]