Move targeting to dedicated datatype within item
This commit is contained in:
@@ -119,7 +119,9 @@ moduleCombinations =
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
makeDirectedTele it = it & itEffect .~ rbSetTarget
|
makeDirectedTele it = it
|
||||||
|
-- & itEffect .~ rbSetTarget
|
||||||
|
& itTargeting' .~ targetRBPress
|
||||||
& itUse . useMods .:~ withPosDirWallCheck directedTelPos
|
& itUse . useMods .:~ withPosDirWallCheck directedTelPos
|
||||||
-- for the camera: the simplest option is to remove all zoom/offset
|
-- for the camera: the simplest option is to remove all zoom/offset
|
||||||
& itUse . useAim . aimZoom . itZoomFac .~ 1
|
& itUse . useAim . aimZoom . itZoomFac .~ 1
|
||||||
@@ -128,9 +130,7 @@ moduleCombinations =
|
|||||||
-- position
|
-- position
|
||||||
directedTelPos it cr w = (p,a)
|
directedTelPos it cr w = (p,a)
|
||||||
where
|
where
|
||||||
p = fromMaybe (_crPos cr) $ do
|
p = fromMaybe (_crPos cr) $ it ^? itTargeting' . tgPos . _Just
|
||||||
(g,_) <- _itTargeting it
|
|
||||||
g w
|
|
||||||
a = argV (mouseWorldPos w -.- p)
|
a = argV (mouseWorldPos w -.- p)
|
||||||
f ameff = itConsumption . aoType . amBulEff .~ ameff
|
f ameff = itConsumption . aoType . amBulEff .~ ameff
|
||||||
amod cts str func = (cts,ItemModule [str] 1 func)
|
amod cts str func = (cts,ItemModule [str] 1 func)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ basicCrPict col cr cfig w =
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
targetingPic = IM.elems $ IM.mapMaybeWithKey f $ _crInv cr
|
targetingPic = IM.elems $ IM.mapMaybeWithKey f $ _crInv cr
|
||||||
f invid it = fmap ((\g -> g invid it cr w) . snd) (it ^? itTargeting . _Just)
|
f invid it = fmap (\g -> g invid it cr w) (it ^? itTargeting' . tgDraw)
|
||||||
|
|
||||||
drawCrEquipment :: Creature -> SPic
|
drawCrEquipment :: Creature -> SPic
|
||||||
drawCrEquipment cr = uncurryV translateSPf (_crPos cr) (rotateSP (_crDir cr) $ drawEquipment cr)
|
drawCrEquipment cr = uncurryV translateSPf (_crPos cr) (rotateSP (_crDir cr) $ drawEquipment cr)
|
||||||
|
|||||||
+1
-2
@@ -369,7 +369,6 @@ data Item = Item
|
|||||||
, _itInvSize :: Float
|
, _itInvSize :: Float
|
||||||
, _itInvDisplay :: Item -> [String]
|
, _itInvDisplay :: Item -> [String]
|
||||||
, _itInvColor :: Color
|
, _itInvColor :: Color
|
||||||
, _itTargeting :: Maybe (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
|
|
||||||
, _itTargeting' :: Targeting
|
, _itTargeting' :: Targeting
|
||||||
, _itDimension :: ItemDimension
|
, _itDimension :: ItemDimension
|
||||||
, _itCurseStatus :: CurseStatus
|
, _itCurseStatus :: CurseStatus
|
||||||
@@ -383,7 +382,7 @@ data Targeting
|
|||||||
| TargetingOnHeld
|
| TargetingOnHeld
|
||||||
{ _tgPos :: Maybe Point2
|
{ _tgPos :: Maybe Point2
|
||||||
, _tgHeldUpdate :: Item -> Creature -> World -> Targeting -> Targeting
|
, _tgHeldUpdate :: Item -> Creature -> World -> Targeting -> Targeting
|
||||||
, _tgDraw :: Item -> Creature -> World -> Picture
|
, _tgDraw :: Int -> Item -> Creature -> World -> Picture
|
||||||
}
|
}
|
||||||
data ModuleSlot
|
data ModuleSlot
|
||||||
= ModBullet
|
= ModBullet
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ defaultEquipment = Item
|
|||||||
, _itAttachment = NoItAttachment
|
, _itAttachment = NoItAttachment
|
||||||
, _itParams = NoParams
|
, _itParams = NoParams
|
||||||
, _itTweaks = NoTweaks
|
, _itTweaks = NoTweaks
|
||||||
, _itTargeting = Nothing
|
|
||||||
, _itModules = M.empty
|
, _itModules = M.empty
|
||||||
, _itScope = NoScope
|
, _itScope = NoScope
|
||||||
, _itTargeting' = NoTargeting
|
, _itTargeting' = NoTargeting
|
||||||
@@ -177,7 +176,6 @@ defaultConsumable = Item
|
|||||||
, _itScroll = \_ _ -> id
|
, _itScroll = \_ _ -> id
|
||||||
, _itAttachment = NoItAttachment
|
, _itAttachment = NoItAttachment
|
||||||
, _itType = NoCombineType
|
, _itType = NoCombineType
|
||||||
, _itTargeting = Nothing
|
|
||||||
, _itParams = NoParams
|
, _itParams = NoParams
|
||||||
, _itDimension = defItDimCol blue
|
, _itDimension = defItDimCol blue
|
||||||
, _itTweaks = NoTweaks
|
, _itTweaks = NoTweaks
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ defaultGun = Item
|
|||||||
, _itInvDisplay = basicItemDisplay
|
, _itInvDisplay = basicItemDisplay
|
||||||
, _itInvColor = white
|
, _itInvColor = white
|
||||||
, _itInvSize = 1
|
, _itInvSize = 1
|
||||||
, _itTargeting = Nothing
|
|
||||||
, _itParams = NoParams
|
, _itParams = NoParams
|
||||||
, _itTweaks = NoTweaks
|
, _itTweaks = NoTweaks
|
||||||
, _itModules = M.fromList [(ModBullet , DefaultModule)
|
, _itModules = M.fromList [(ModBullet , DefaultModule)
|
||||||
@@ -121,7 +120,6 @@ defaultCraftable = Item
|
|||||||
, _itInvDisplay = basicItemDisplay
|
, _itInvDisplay = basicItemDisplay
|
||||||
, _itInvColor = green
|
, _itInvColor = green
|
||||||
, _itInvSize = 1
|
, _itInvSize = 1
|
||||||
, _itTargeting = Nothing
|
|
||||||
, _itParams = NoParams
|
, _itParams = NoParams
|
||||||
, _itDimension = defItDimCol green
|
, _itDimension = defItDimCol green
|
||||||
, _itTweaks = NoTweaks
|
, _itTweaks = NoTweaks
|
||||||
|
|||||||
@@ -40,11 +40,12 @@ bezierGun = defaultGun
|
|||||||
-- , _itFloorPict = bezierGunSPic
|
-- , _itFloorPict = bezierGunSPic
|
||||||
, _itAttachment = NoItAttachment
|
, _itAttachment = NoItAttachment
|
||||||
, _itScroll = \_ _ -> removeItTarget
|
, _itScroll = \_ _ -> removeItTarget
|
||||||
, _itEffect = rbSetTarget
|
-- , _itEffect = rbSetTarget
|
||||||
-- , _itZoom = defaultItZoom
|
-- , _itZoom = defaultItZoom
|
||||||
, _itConsumption = defaultAmmo
|
, _itConsumption = defaultAmmo
|
||||||
{ _ammoBaseMax = 15
|
{ _ammoBaseMax = 15
|
||||||
}
|
}
|
||||||
|
, _itTargeting' = targetRBPress
|
||||||
}
|
}
|
||||||
shootBezier :: Point2 -> Creature -> World -> World
|
shootBezier :: Point2 -> Creature -> World -> World
|
||||||
shootBezier targetp cr w = w & particles .:~ aCurveBulAt
|
shootBezier targetp cr w = w & particles .:~ aCurveBulAt
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ bangStick i = defaultGun
|
|||||||
]
|
]
|
||||||
, _itID = Nothing
|
, _itID = Nothing
|
||||||
, _itInvColor = white
|
, _itInvColor = white
|
||||||
, _itTargeting = Nothing
|
|
||||||
, _itParams = BulletShooter
|
, _itParams = BulletShooter
|
||||||
{ _muzVel = 0.8
|
{ _muzVel = 0.8
|
||||||
, _rifling = 0.8
|
, _rifling = 0.8
|
||||||
@@ -185,7 +184,6 @@ pistol = (bangStick 1)
|
|||||||
-- , _itEquipPict = pictureWeaponAim pistolPic
|
-- , _itEquipPict = pictureWeaponAim pistolPic
|
||||||
, _itID = Nothing
|
, _itID = Nothing
|
||||||
, _itInvColor = white
|
, _itInvColor = white
|
||||||
, _itTargeting = Nothing
|
|
||||||
, _itParams = BulletShooter
|
, _itParams = BulletShooter
|
||||||
{ _muzVel = 0.8
|
{ _muzVel = 0.8
|
||||||
, _rifling = 0.8
|
, _rifling = 0.8
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ module Dodge.Item.Weapon.ExtraEffect
|
|||||||
itemLaserScopeEffect
|
itemLaserScopeEffect
|
||||||
, autoSonarEffect
|
, autoSonarEffect
|
||||||
, autoRadarEffect
|
, autoRadarEffect
|
||||||
, rbSetTarget
|
, targetRBPress
|
||||||
|
-- , rbSetTarget
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
@@ -81,19 +82,43 @@ autoSonarEffect = ItInvEffect {_itInvEffect = f 50 ,_itEffectCounter = 0 }
|
|||||||
f t _ cr i w = w
|
f t _ cr i w = w
|
||||||
& creatures . ix (_crID cr) . crInv . ix i . itEffect . itInvEffect .~ f (t-1)
|
& creatures . ix (_crID cr) . crInv . ix i . itEffect . itInvEffect .~ f (t-1)
|
||||||
|
|
||||||
rbSetTarget :: ItEffect
|
targetRBPress :: Targeting
|
||||||
rbSetTarget = ItInvEffect
|
targetRBPress = TargetingOnHeld
|
||||||
{_itInvEffect = setTarg
|
{ _tgPos = Nothing
|
||||||
,_itEffectCounter = 0
|
, _tgHeldUpdate = targetRBPressUpdate
|
||||||
|
, _tgDraw = targetRBPressDraw
|
||||||
}
|
}
|
||||||
|
targetRBPressDraw :: Int -> Item -> Creature -> World -> Picture
|
||||||
|
targetRBPressDraw _ it _ w' = fromMaybe mempty $ do
|
||||||
|
mwp <- it ^? itTargeting' . tgPos . _Just
|
||||||
|
return $ setLayer 1 $ color red $ onLayer InvLayer $ uncurryV translate mwp
|
||||||
|
$ rotate (_cameraRot w')
|
||||||
|
$ pictures
|
||||||
|
[line [V2 x x, V2 (-x) (-x)]
|
||||||
|
,line [V2 (-x) x, V2 x (-x)]
|
||||||
|
]
|
||||||
where
|
where
|
||||||
setTarg :: ItEffect -> Creature -> Int -> World -> World
|
x = 5 / _cameraZoom w'
|
||||||
setTarg _ cr invid w
|
|
||||||
| _crInvSel cr /= invid = w
|
targetRBPressUpdate :: Item -> Creature -> World -> Targeting -> Targeting
|
||||||
| SDL.ButtonRight `S.member` _mouseButtons w = w
|
targetRBPressUpdate _ _ w t
|
||||||
& creatures . ix (_crID cr) . crInv . ix invid . itTargeting
|
| SDL.ButtonRight `S.member` _mouseButtons w = t
|
||||||
%~ maybe (Just $ targetRBMousePos w) Just
|
& tgPos %~ maybe (Just $ mouseWorldPos w) Just
|
||||||
| otherwise = w & creatures . ix (_crID cr) . crInv . ix invid . itTargeting .~ Nothing
|
| otherwise = t & tgPos %~ const Nothing
|
||||||
|
|
||||||
|
--rbSetTarget :: ItEffect
|
||||||
|
--rbSetTarget = ItInvEffect
|
||||||
|
-- {_itInvEffect = setTarg
|
||||||
|
-- ,_itEffectCounter = 0
|
||||||
|
-- }
|
||||||
|
-- where
|
||||||
|
-- setTarg :: ItEffect -> Creature -> Int -> World -> World
|
||||||
|
-- setTarg _ cr invid w
|
||||||
|
-- | _crInvSel cr /= invid = w
|
||||||
|
-- | SDL.ButtonRight `S.member` _mouseButtons w = w
|
||||||
|
-- & creatures . ix (_crID cr) . crInv . ix invid . itTargeting
|
||||||
|
-- %~ maybe (Just $ targetRBMousePos w) Just
|
||||||
|
-- | otherwise = w & creatures . ix (_crID cr) . crInv . ix invid . itTargeting .~ Nothing
|
||||||
|
|
||||||
targetRBMousePos
|
targetRBMousePos
|
||||||
:: World
|
:: World
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ useTargetPos
|
|||||||
-> Creature
|
-> Creature
|
||||||
-> World
|
-> World
|
||||||
-> World
|
-> World
|
||||||
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting . _Just of
|
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting' . tgPos of
|
||||||
Nothing -> w
|
Nothing -> w
|
||||||
Just (g,_) -> f (g w) cr w
|
Just p -> f p cr w
|
||||||
|
|
||||||
removeItTarget :: Item -> Item
|
removeItTarget :: Item -> Item
|
||||||
removeItTarget = itTargeting .~ Nothing
|
removeItTarget = itTargeting' . tgPos .~ Nothing
|
||||||
|
|||||||
Reference in New Issue
Block a user