Move towards allowing equipable targeting items

This commit is contained in:
2023-01-06 11:01:32 +00:00
parent bf479ca080
commit 612ee85579
23 changed files with 152 additions and 145 deletions
+15 -16
View File
@@ -9,21 +9,20 @@ import LensHelp
import Picture
import ShortShow
drawTargeting :: TargetType -> Item -> Creature -> Configuration -> World -> Picture
drawTargeting :: TargetType -> Creature -> Configuration -> World -> Picture
drawTargeting td = case td of
-- NoTargetDraw -> \_ _ _ _ -> mempty
TargetRBCreature -> targetRBCreatureDraw
TargetRBLine -> targetDistanceDraw
TargetLaser -> \_ _ _ _ -> mempty
TargetLaser -> \_ _ _ -> mempty
TargetRBPress -> targetSimpleDraw
TargetCursor -> targetSimpleDraw
targetSimpleDraw :: Item -> Creature -> Configuration -> World -> Picture
targetSimpleDraw = targetDraw $ const activeTargetCursorPic
targetSimpleDraw :: Creature -> Configuration -> World -> Picture
targetSimpleDraw = targetDraw $ activeTargetCursorPic
targetDistanceDraw :: Item -> Creature -> Configuration -> World -> Picture
targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do
p <- itm ^? itUse . heldTargeting . tgPos . _Just
targetDistanceDraw :: Creature -> Configuration -> World -> Picture
targetDistanceDraw cr cfig w = fromMaybe mempty $ do
p <- cr ^? crTargeting . ctPos . _Just
let p1 = worldPosToScreen cam p
mwp = mouseWorldPos (w ^. input) (w ^. cWorld . camPos)
p2 = worldPosToScreen cam mwp
@@ -37,15 +36,15 @@ targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do
where
cam = w ^. cWorld . camPos
targetDraw :: (Item -> Picture) -> Item -> Creature -> Configuration -> World -> Picture
targetDraw f it _ cfig w = fromMaybe mempty $ do
p <- it ^? itUse . heldTargeting . tgPos . _Just
targetDraw :: Picture -> Creature -> Configuration -> World -> Picture
targetDraw f cr cfig w = fromMaybe mempty $ do
p <- cr ^? crTargeting . ctPos . _Just
return $
winScale cfig $
setLayer FixedCoordLayer $
color white $
uncurryV translate (worldPosToScreen cam p) $
f it
f
where
cam = w ^. cWorld . camPos
@@ -63,11 +62,11 @@ transMidLine p1 p2 = translate 20 (f p1 p2) . uncurryV translate (0.5 *.* (p1 +.
| x > x' = min 10 (x - x')
| otherwise = max (-10) (x - x')
targetRBCreatureDraw :: Item -> Creature -> Configuration -> World -> Picture
targetRBCreatureDraw = targetDraw thepic
targetRBCreatureDraw :: Creature -> Configuration -> World -> Picture
targetRBCreatureDraw cr = targetDraw thepic cr
where
thepic it
| _tgActive $ _heldTargeting $ _itUse it = activeTargetCursorPic
thepic
| _ctActive $ _crTargeting $ cr = activeTargetCursorPic
| otherwise = targetCursorPic
targCorner :: Picture