This commit is contained in:
2022-02-22 22:07:55 +00:00
parent 8a7d06783d
commit 1e5f24c8a1
9 changed files with 20 additions and 49 deletions
+2 -3
View File
@@ -120,8 +120,7 @@ moduleCombinations =
]
where
makeDirectedTele it = it
-- & itEffect .~ rbSetTarget
& itTargeting' .~ targetRBPress
& itTargeting .~ targetRBPress
& itUse . useMods .:~ withPosDirWallCheck directedTelPos
-- for the camera: the simplest option is to remove all zoom/offset
& itUse . useAim . aimZoom . itZoomFac .~ 1
@@ -130,7 +129,7 @@ moduleCombinations =
-- position
directedTelPos it cr w = (p,a)
where
p = fromMaybe (_crPos cr) $ it ^? itTargeting' . tgPos . _Just
p = fromMaybe (_crPos cr) $ it ^? itTargeting . tgPos . _Just
a = argV (mouseWorldPos w -.- p)
f ameff = itConsumption . aoType . amBulEff .~ ameff
amod cts str func = (cts,ItemModule [str] 1 func)
+1 -1
View File
@@ -42,7 +42,7 @@ basicCrPict col cr cfig w =
)
where
targetingPic = IM.elems $ IM.mapMaybeWithKey f $ _crInv cr
f invid it = fmap (\g -> g invid it cr w) (it ^? itTargeting' . tgDraw)
f invid it = fmap (\g -> g invid it cr w) (it ^? itTargeting . tgDraw)
drawCrEquipment :: Creature -> SPic
drawCrEquipment cr = uncurryV translateSPf (_crPos cr) (rotateSP (_crDir cr) $ drawEquipment cr)
+2 -2
View File
@@ -150,9 +150,9 @@ invSideEff cr w = weaponReloadSounds cr
itpointer = creatures . ix (_crID cr) . crInv . ix i
doHeldItemTargeting :: Creature -> World -> World
doHeldItemTargeting cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting' . tgHeldUpdate of
doHeldItemTargeting cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting . tgHeldUpdate of
Nothing -> w
Just f -> w & creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itTargeting'
Just f -> w & creatures . ix (_crID cr) . crInv . ix (_crInvSel cr) . itTargeting
%~ f (_crInv cr IM.! _crInvSel cr) cr w
weaponReloadSounds :: Creature -> World -> World
+1 -1
View File
@@ -369,7 +369,7 @@ data Item = Item
, _itInvSize :: Float
, _itInvDisplay :: Item -> [String]
, _itInvColor :: Color
, _itTargeting' :: Targeting
, _itTargeting :: Targeting
, _itDimension :: ItemDimension
, _itCurseStatus :: CurseStatus
, _itParams :: ItemParams
+2 -2
View File
@@ -156,7 +156,7 @@ defaultEquipment = Item
, _itTweaks = NoTweaks
, _itModules = M.empty
, _itScope = NoScope
, _itTargeting' = NoTargeting
, _itTargeting = NoTargeting
}
defaultItZoom :: ItZoom
defaultItZoom = ItZoom 20 0.2 1
@@ -181,7 +181,7 @@ defaultConsumable = Item
, _itTweaks = NoTweaks
, _itModules = M.empty
, _itScope = NoScope
, _itTargeting' = NoTargeting
, _itTargeting = NoTargeting
}
defaultApplyDamage :: [DamageType] -> Creature -> (World -> World, Creature)
defaultApplyDamage ds cr = (id, doPoisonDam $ foldl' (flip $ \d c -> snd $ applyIndividualDamage d c) cr ds')
+2 -2
View File
@@ -103,7 +103,7 @@ defaultGun = Item
,(ModBulletTarget,DefaultModule)
]
, _itScope = NoScope
, _itTargeting' = NoTargeting
, _itTargeting = NoTargeting
}
defaultCraftable :: Item
defaultCraftable = Item
@@ -125,7 +125,7 @@ defaultCraftable = Item
, _itTweaks = NoTweaks
, _itModules = M.empty
, _itScope = NoScope
, _itTargeting' = NoTargeting
, _itTargeting = NoTargeting
}
defItDim :: ItemDimension
defItDim = ItemDimension
+1 -1
View File
@@ -45,7 +45,7 @@ bezierGun = defaultGun
, _itConsumption = defaultAmmo
{ _ammoBaseMax = 15
}
, _itTargeting' = targetRBPress
, _itTargeting = targetRBPress
}
shootBezier :: Point2 -> Creature -> World -> World
shootBezier targetp cr w = w & particles .:~ aCurveBulAt
+4 -34
View File
@@ -89,49 +89,19 @@ targetRBPress = TargetingOnHeld
, _tgDraw = targetRBPressDraw
}
targetRBPressDraw :: Int -> Item -> Creature -> World -> Picture
targetRBPressDraw _ it _ w' = fromMaybe mempty $ do
mwp <- it ^? itTargeting' . tgPos . _Just
targetRBPressDraw _ it _ w = fromMaybe mempty $ do
mwp <- it ^? itTargeting . tgPos . _Just
return $ setLayer 1 $ color red $ onLayer InvLayer $ uncurryV translate mwp
$ rotate (_cameraRot w')
$ rotate (_cameraRot w)
$ pictures
[line [V2 x x, V2 (-x) (-x)]
,line [V2 (-x) x, V2 x (-x)]
]
where
x = 5 / _cameraZoom w'
x = 5 / _cameraZoom w
targetRBPressUpdate :: Item -> Creature -> World -> Targeting -> Targeting
targetRBPressUpdate _ _ w t
| SDL.ButtonRight `S.member` _mouseButtons w = t
& tgPos %~ maybe (Just $ mouseWorldPos w) Just
| 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
:: World
-> (World -> Maybe Point2, Int -> Item -> Creature -> World -> Picture)
targetRBMousePos w = (f, \_ _ _ w' -> cursorPic w')
where
f _ = Just mwp
mwp = mouseWorldPos w
cursorPic w' = 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
x = 5 / _cameraZoom w'
+5 -3
View File
@@ -1,5 +1,7 @@
module Dodge.Item.Weapon.Targeting
where
( useTargetPos
, removeItTarget
) where
import Dodge.Data
import Geometry.Data
@@ -10,9 +12,9 @@ useTargetPos
-> Creature
-> World
-> World
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting' . tgPos of
useTargetPos f cr w = case cr ^? crInv . ix (_crInvSel cr) . itTargeting . tgPos of
Nothing -> w
Just p -> f p cr w
removeItTarget :: Item -> Item
removeItTarget = itTargeting' . tgPos .~ Nothing
removeItTarget = itTargeting . tgPos .~ Nothing