diff --git a/src/Dodge/Combine/Combinations.hs b/src/Dodge/Combine/Combinations.hs index 82f6b3b1a..c8f7d187a 100644 --- a/src/Dodge/Combine/Combinations.hs +++ b/src/Dodge/Combine/Combinations.hs @@ -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) diff --git a/src/Dodge/Creature/Picture.hs b/src/Dodge/Creature/Picture.hs index fb6a3250b..16b1be75c 100644 --- a/src/Dodge/Creature/Picture.hs +++ b/src/Dodge/Creature/Picture.hs @@ -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) diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index e1b519474..0024dca16 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -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 diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index a83dd2427..2dd6a662e 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -369,7 +369,7 @@ data Item = Item , _itInvSize :: Float , _itInvDisplay :: Item -> [String] , _itInvColor :: Color - , _itTargeting' :: Targeting + , _itTargeting :: Targeting , _itDimension :: ItemDimension , _itCurseStatus :: CurseStatus , _itParams :: ItemParams diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index 8a0487fa4..c11e62657 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -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') diff --git a/src/Dodge/Default/Weapon.hs b/src/Dodge/Default/Weapon.hs index c178c4db3..39232e683 100644 --- a/src/Dodge/Default/Weapon.hs +++ b/src/Dodge/Default/Weapon.hs @@ -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 diff --git a/src/Dodge/Item/Weapon/Bezier.hs b/src/Dodge/Item/Weapon/Bezier.hs index 06c0a29bd..6e1bfdb95 100644 --- a/src/Dodge/Item/Weapon/Bezier.hs +++ b/src/Dodge/Item/Weapon/Bezier.hs @@ -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 diff --git a/src/Dodge/Item/Weapon/ExtraEffect.hs b/src/Dodge/Item/Weapon/ExtraEffect.hs index cf9202db1..97a4dc8a0 100644 --- a/src/Dodge/Item/Weapon/ExtraEffect.hs +++ b/src/Dodge/Item/Weapon/ExtraEffect.hs @@ -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' diff --git a/src/Dodge/Item/Weapon/Targeting.hs b/src/Dodge/Item/Weapon/Targeting.hs index 0379ddb07..84507d87b 100644 --- a/src/Dodge/Item/Weapon/Targeting.hs +++ b/src/Dodge/Item/Weapon/Targeting.hs @@ -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