Add fields to determine an item's inventory position/whether it is held
This commit is contained in:
@@ -52,51 +52,64 @@ autoSonarEffect = ItInvEffect {_itInvEffect = f 50 ,_itEffectCounter = 0 }
|
||||
defaultTargeting :: Targeting
|
||||
defaultTargeting = TargetingOnHeld
|
||||
{ _tgPos = Nothing
|
||||
, _tgUpdate = \_ _ w t -> (w,t)
|
||||
, _tgHeldUpdate = \_ _ w t -> (w,t)
|
||||
, _tgNotHeldUpdate = \_ _ w t -> (w,t)
|
||||
, _tgDraw = \_ _ _ _ -> mempty
|
||||
, _tgID = Nothing
|
||||
, _tgActive = False
|
||||
}
|
||||
targetLaser :: Targeting
|
||||
targetLaser = defaultTargeting
|
||||
& tgUpdate .~ targetLaserUpdate
|
||||
& tgHeldUpdate .~ targetLaserUpdate
|
||||
targetRBPress :: Targeting
|
||||
targetRBPress = defaultTargeting
|
||||
& tgUpdate .~ targetUpdateWith targetRBPressUpdate
|
||||
& tgHeldUpdate .~ targetUpdateWith targetRBPressUpdate
|
||||
& tgDraw .~ targetSimpleDraw
|
||||
targetRBCreature :: Targeting
|
||||
targetRBCreature = defaultTargeting
|
||||
& tgUpdate .~ targetUpdateWith targetRBCreatureUpdate
|
||||
& tgHeldUpdate .~ targetUpdateWith targetRBCreatureUpdate
|
||||
& tgNotHeldUpdate .~ targetUpdateWith
|
||||
(const ((tgID .~ Nothing) . (tgPos .~ Nothing) . (tgActive .~ False)))
|
||||
-- undefined
|
||||
& tgDraw .~ targetRBCreatureDraw
|
||||
targetCursor :: Targeting
|
||||
targetCursor = defaultTargeting
|
||||
& tgUpdate .~ targetUpdateWith targetCursorUpdate
|
||||
& tgHeldUpdate .~ targetUpdateWith targetCursorUpdate
|
||||
& tgDraw .~ targetSimpleDraw
|
||||
targetSimpleDraw :: Int -> Item -> Creature -> World -> Picture
|
||||
targetSimpleDraw _ it _ w = fromMaybe mempty $ do
|
||||
mwp <- it ^? itTargeting . tgPos . _Just
|
||||
return $ setLayer DebugLayer $ color red $ setDepth 50 $ uncurryV translate mwp
|
||||
$ rotate (_cameraRot w)
|
||||
$ pictures
|
||||
[line [V2 x x, V2 (-x) (-x)]
|
||||
,line [V2 (-x) x, V2 x (-x)]
|
||||
]
|
||||
where
|
||||
x = 5 / _cameraZoom w
|
||||
targetSimpleDraw :: Int -> Item -> Creature -> Configuration -> World -> Picture
|
||||
targetSimpleDraw _ it _ cfig w = fromMaybe mempty $ do
|
||||
p <- it ^? itTargeting . tgPos . _Just
|
||||
return $ winScale cfig $ setLayer FixedCoordLayer $ color white
|
||||
$ uncurryV translate (worldPosToScreen w p)
|
||||
-- $ rotate (_cameraRot w)
|
||||
$ activeTargetCursorPic
|
||||
|
||||
targetRBCreatureDraw :: Int -> Item -> Creature -> World -> Picture
|
||||
targetRBCreatureDraw _ it _ w = fromMaybe mempty $ do
|
||||
mwp <- it ^? itTargeting . tgPos . _Just
|
||||
return $ setLayer DebugLayer $ color thecolor $ setDepth 50 $ uncurryV translate mwp
|
||||
$ rotate (_cameraRot w)
|
||||
$ pictures
|
||||
[line [V2 x x, V2 (-x) (-x)]
|
||||
,line [V2 (-x) x, V2 x (-x)]
|
||||
]
|
||||
targetRBCreatureDraw :: Int -> Item -> Creature -> Configuration -> World -> Picture
|
||||
targetRBCreatureDraw _ it _ cfig w = fromMaybe mempty $ do
|
||||
p <- it ^? itTargeting . tgPos . _Just
|
||||
return $ winScale cfig $ setLayer FixedCoordLayer $ color white
|
||||
$ uncurryV translate (worldPosToScreen w p)
|
||||
-- $ rotate (_cameraRot w)
|
||||
$ thepic
|
||||
where
|
||||
x = 5 / _cameraZoom w
|
||||
thecolor | _tgActive $ _itTargeting it = red
|
||||
| otherwise = blue
|
||||
thepic | _tgActive $ _itTargeting it = activeTargetCursorPic
|
||||
| otherwise = targetCursorPic
|
||||
|
||||
activeTargetCursorPic :: Picture
|
||||
activeTargetCursorPic = pictures
|
||||
[rotate a $ line [V2 15 0,V2 10 0] <> targCorner | a <- [0,0.5*pi,pi,1.5*pi]]
|
||||
|
||||
targetCursorPic :: Picture
|
||||
targetCursorPic = pictures
|
||||
[rotate a targCorner | a <- [0,0.5*pi,pi,1.5*pi]]
|
||||
targCorner :: Picture
|
||||
targCorner = pictures
|
||||
[line [V2 x x, V2 x (x-y)]
|
||||
,line [V2 x x, V2 (x-y) x]
|
||||
]
|
||||
where
|
||||
x = 10
|
||||
y = 5
|
||||
|
||||
targetUpdateWith :: (World -> Targeting -> Targeting)
|
||||
-> Item -> Creature -> World -> Targeting -> (World,Targeting)
|
||||
|
||||
Reference in New Issue
Block a user