diff --git a/src/Dodge/Bullet.hs b/src/Dodge/Bullet.hs index ccb8b2df7..643c7ede9 100644 --- a/src/Dodge/Bullet.hs +++ b/src/Dodge/Bullet.hs @@ -71,13 +71,13 @@ useAmmoParams it cr w = settrajectory traj = case traj of BasicBulletTrajectory -> BasicBulletTrajectory MagnetTrajectory{} -> fromMaybe BasicBulletTrajectory $ do - tpos <- it ^? itTargeting . tgPos . _Just + tpos <- it ^? itUse . heldTargeting . tgPos . _Just return $ MagnetTrajectory tpos FlechetteTrajectory{} -> fromMaybe BasicBulletTrajectory $ do - tpos <- it ^? itTargeting . tgPos . _Just + tpos <- it ^? itUse . heldTargeting . tgPos . _Just return $ FlechetteTrajectory tpos BezierTrajectory{} -> fromMaybe BasicBulletTrajectory $ do - tpos <- it ^? itTargeting . tgPos . _Just + tpos <- it ^? itUse . heldTargeting . tgPos . _Just return $ BezierTrajectory sp tpos (mouseWorldPos (w ^. input) (w ^. cWorld . camPos)) bounceDir :: (Point2, Either Creature Wall) -> Maybe Point2 diff --git a/src/Dodge/Combine/Combinations.hs b/src/Dodge/Combine/Combinations.hs index 0f0c79bcd..928dcba82 100644 --- a/src/Dodge/Combine/Combinations.hs +++ b/src/Dodge/Combine/Combinations.hs @@ -167,9 +167,9 @@ moduleCombinations = ( ModTarget , homingLaunchers ++ bulletWeapons , - [ amod [cr MICROCHIP, cr HEATSENSOR] TARGCR - , amod [cr MICROCHIP, cr LIGHTSENSOR] TARGLAS - , amod [cr MICROCHIP, cr SOUNDSENSOR] TARGPOS + [ amod [cr MICROCHIP, cr HEATSENSOR] (TARGET TargetRBCreature) + , amod [cr MICROCHIP, cr LIGHTSENSOR] (TARGET TargetLaser) + , amod [cr MICROCHIP, cr SOUNDSENSOR] (TARGET TargetRBPress) ] ) , diff --git a/src/Dodge/Combine/Module.hs b/src/Dodge/Combine/Module.hs index 61414e03d..d2e9e3c26 100644 --- a/src/Dodge/Combine/Module.hs +++ b/src/Dodge/Combine/Module.hs @@ -19,9 +19,7 @@ moduleModification imt = case imt of PENBUL -> itUse . heldConsumption . laAmmoType . amBullet . buEffect .~ PenetrateBullet STATICBUL -> itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ BulBall TeslaBall CONCUSBUL -> itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ BulBall ConcBall - TARGCR -> itTargeting .~ targetRBCreature - TARGLAS -> itTargeting .~ targetLaser - TARGPOS -> itTargeting .~ targetRBPress + TARGET t -> itUse . heldTargeting .~ (defaultTargeting & tgType .~ t) MAGNETTRAJ -> (itUse . heldConsumption . laAmmoType . amBullet . buTrajectory .~ MagnetTrajectory 0) . (itUse . heldConsumption . laAmmoType . amBullet . buVel .~ V2 10 0) @@ -39,7 +37,7 @@ moduleModification imt = case imt of where makeDirectedTele it = it - & itTargeting .~ targetRBPress + & itUse . heldTargeting .~ (defaultTargeting & tgType .~ TargetRBPress) & itUse . heldMods %~ ModWithDirectedTeleport -- .:~ withPosDirWallCheck directedTelPos -- for the camera: the simplest option is to remove all zoom/offset & itUse . heldAim . aimZoom . izFac .~ 1 diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index 54b11c785..7b8062348 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -270,12 +270,12 @@ updateAutoRecharge it = case it ^? itUse . leftConsumption of _ -> it doItemTargeting :: Int -> Creature -> World -> World -doItemTargeting invid cr w = case cr ^? crInv . ix invid . itTargeting of +doItemTargeting invid cr w = case cr ^? crInv . ix invid . itUse . heldTargeting of Nothing -> w Just NoTargeting -> w Just t -> - let (w', t') = updateTargeting (_tgUpdate t) (_crInv cr IM.! invid) cr w t - in w' & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itTargeting .~ t' + let (w', t') = updateTargeting (_tgType t) (_crInv cr IM.! invid) cr w t + in w' & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . heldTargeting .~ t' weaponReloadSounds :: Creature -> World -> World weaponReloadSounds cr w = case cr ^? crInvSel . iselAction of diff --git a/src/Dodge/Data/Item.hs b/src/Dodge/Data/Item.hs index dad8d93b0..ae308ee55 100644 --- a/src/Dodge/Data/Item.hs +++ b/src/Dodge/Data/Item.hs @@ -13,7 +13,6 @@ module Dodge.Data.Item ( module Dodge.Data.Item.CurseStatus, module Dodge.Data.Item.Scope, module Dodge.Data.Item.Combine, - module Dodge.Data.Item.Targeting, module Dodge.Data.Item.Location, ) where @@ -29,7 +28,6 @@ import Dodge.Data.Item.Misc import Dodge.Data.Item.Params import Dodge.Data.Item.Tweak import Dodge.Data.Item.Use -import Dodge.Data.Item.Targeting import Dodge.Data.Item.Location data Item = Item @@ -41,7 +39,6 @@ data Item = Item , _itEffect :: ItEffect , _itInvSize :: Float , _itInvColor :: Color - , _itTargeting :: Targeting , _itDimension :: ItemDimension , _itCurseStatus :: CurseStatus , _itTweaks :: ItemTweaks diff --git a/src/Dodge/Data/Item/Combine.hs b/src/Dodge/Data/Item/Combine.hs index e0ca2832b..d59476b6c 100644 --- a/src/Dodge/Data/Item/Combine.hs +++ b/src/Dodge/Data/Item/Combine.hs @@ -5,6 +5,7 @@ module Dodge.Data.Item.Combine where +import Dodge.Data.Item.Targeting import Control.Lens import Data.Aeson import Data.Aeson.TH @@ -187,9 +188,7 @@ data ItemModuleType | PENBUL | STATICBUL | CONCUSBUL - | TARGCR - | TARGLAS - | TARGPOS + | TARGET TargetType | MAGNETTRAJ | FLECHETRAJ | BEZIERTRAJ diff --git a/src/Dodge/Data/Item/Targeting.hs b/src/Dodge/Data/Item/Targeting.hs index 14afa38de..bc4440c47 100644 --- a/src/Dodge/Data/Item/Targeting.hs +++ b/src/Dodge/Data/Item/Targeting.hs @@ -14,29 +14,21 @@ data Targeting = NoTargeting | Targeting { _tgPos :: Maybe Point2 - , _tgUpdate :: TargetUpdate --Item -> Creature -> World -> Targeting -> (World, Targeting) - , _tgDraw :: TargetDraw --Item -> Creature -> Configuration -> World -> Picture + , _tgType :: TargetType --Item -> Creature -> World -> Targeting -> (World, Targeting) +-- , _tgDraw :: TargetDraw --Item -> Creature -> Configuration -> World -> Picture , _tgID :: Maybe Int , _tgActive :: Bool } deriving (Eq, Ord, Show, Read) --Generic, Flat) -data TargetUpdate - = NoTargetUpdate - | TargetLaserUpdate - | TargetRBPressUpdate - | TargetRBCreatureUpdate - | TargetCursorUpdate - deriving (Eq, Ord, Show, Read) --Generic, Flat) - -data TargetDraw - = NoTargetDraw - | TargetDistanceDraw - | SimpleDrawTarget - | TargetRBCreatureDraw +data TargetType + = TargetLaser + | TargetRBPress + | TargetRBLine + | TargetRBCreature + | TargetCursor deriving (Eq, Ord, Show, Read) --Generic, Flat) makeLenses ''Targeting -deriveJSON defaultOptions ''TargetUpdate -deriveJSON defaultOptions ''TargetDraw +deriveJSON defaultOptions ''TargetType deriveJSON defaultOptions ''Targeting diff --git a/src/Dodge/Data/Item/Use.hs b/src/Dodge/Data/Item/Use.hs index 2cdef8a74..0602fad84 100644 --- a/src/Dodge/Data/Item/Use.hs +++ b/src/Dodge/Data/Item/Use.hs @@ -11,6 +11,7 @@ module Dodge.Data.Item.Use ( module Dodge.Data.Item.HeldDelay, module Dodge.Data.Item.Use.Consumption, module Dodge.Data.Hammer, + module Dodge.Data.Item.Targeting, ) where import Control.Lens @@ -22,6 +23,7 @@ import Dodge.Data.Item.HeldUse import Dodge.Data.Item.Use.Consumption import Dodge.Data.Item.Use.Equipment import Dodge.Data.Item.HeldDelay +import Dodge.Data.Item.Targeting data ItemUse = HeldUse @@ -32,6 +34,7 @@ data ItemUse , _heldAim :: AimParams , _heldScroll :: HeldScroll , _heldConsumption :: HeldConsumption + , _heldTargeting :: Targeting } | LeftUse { _leftUse :: Luse @@ -46,6 +49,7 @@ data ItemUse } | EquipUse { _equipEffect :: EquipEffect + , _equipTargeting :: Targeting } | CraftUse {_useAmount :: ItAmount} diff --git a/src/Dodge/Data/Laser.hs b/src/Dodge/Data/Laser.hs index 4c6941d55..3746a0448 100644 --- a/src/Dodge/Data/Laser.hs +++ b/src/Dodge/Data/Laser.hs @@ -13,7 +13,7 @@ import Geometry.Data data LaserType = DamageLaser {_laserTypeDamage :: Int} - | TargetLaser + | TargetingLaser deriving (Eq, Ord, Show, Read) --Generic, Flat) data LaserStart = LaserStart diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index 821b06bbf..27bb951b2 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -28,9 +28,7 @@ defaultEquipment :: Item defaultEquipment = defaultItem & itInvColor .~ yellow - & itUse .~ EquipUse defaultEquip - - + & itUse .~ defaultEquipUse defaultFlIt :: FloorItem defaultFlIt = FlIt{_flItRot = 0, _flIt = defaultConsumable, _flItPos = V2 0 0, _flItID = 0} diff --git a/src/Dodge/Default/Item.hs b/src/Dodge/Default/Item.hs index e3acd98da..4fdf0bf99 100644 --- a/src/Dodge/Default/Item.hs +++ b/src/Dodge/Default/Item.hs @@ -35,7 +35,6 @@ defaultItem = , _itParams = NoParams , _itTweaks = NoTweaks , _itScope = NoScope - , _itTargeting = NoTargeting -- , _itValue = ItemValue 0 MundaneItem } diff --git a/src/Dodge/Default/Item/Use.hs b/src/Dodge/Default/Item/Use.hs index c77a66b0c..fe8f2c81e 100644 --- a/src/Dodge/Default/Item/Use.hs +++ b/src/Dodge/Default/Item/Use.hs @@ -21,7 +21,10 @@ defaultLeftUse = } defaultEquipUse :: ItemUse -defaultEquipUse = EquipUse{_equipEffect = defaultEquip} +defaultEquipUse = EquipUse + { _equipEffect = defaultEquip + , _equipTargeting = NoTargeting + } defaultHeldUse :: ItemUse defaultHeldUse = @@ -33,4 +36,5 @@ defaultHeldUse = , _heldAim = defaultAimParams , _heldScroll = HeldScrollDoNothing , _heldConsumption = defaultLoadable + , _heldTargeting = NoTargeting } diff --git a/src/Dodge/HeldUse.hs b/src/Dodge/HeldUse.hs index d3f9515af..2579dff12 100644 --- a/src/Dodge/HeldUse.hs +++ b/src/Dodge/HeldUse.hs @@ -348,7 +348,7 @@ useMod hm = case hm of thegapDualBeam = _dbGap . _itParams directedTelPos it cr w = (p, a) where - p = fromMaybe (_crPos cr) $ it ^? itTargeting . tgPos . _Just + p = fromMaybe (_crPos cr) $ it ^? itUse . heldTargeting . tgPos . _Just a = argV (mouseWorldPos (w ^. input) (w ^. cWorld . camPos) -.- p) moddelay x = itUse . heldConsumption . laAmmoType . amBullet . buDelayFraction .~ x modcrpos x cr = @@ -511,7 +511,7 @@ shootTeslaArc it cr w = -- TODO investigate more and fix useForceFieldGun :: Item -> Creature -> World -> World useForceFieldGun itm cr w = fromMaybe w $ do - a <- _tgPos $ _itTargeting itm + a <- _tgPos . _heldTargeting $ _itUse itm let mwp = mouseWorldPos (w ^. input) (w ^. cWorld . camPos) b = if dist a mwp < 100 then mwp else a +.+ 100 *.* normalizeV (mwp -.- a) wlline = (a, b) diff --git a/src/Dodge/Item/Display.hs b/src/Dodge/Item/Display.hs index 9463d0740..2d1fee7c2 100644 --- a/src/Dodge/Item/Display.hs +++ b/src/Dodge/Item/Display.hs @@ -75,7 +75,7 @@ showConsumption :: ItemUse -> String showConsumption iu = case iu of HeldUse{} -> showReloadProgress' (_heldConsumption iu) LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu) - EquipUse ee -> showEUseNumber ee + EquipUse {_equipEffect = ee} -> showEUseNumber ee _ -> show $ iu ^?! useAmount . getItAmount showEUseNumber :: EquipEffect -> String diff --git a/src/Dodge/Item/Held/Rod.hs b/src/Dodge/Item/Held/Rod.hs index 3a1dc48b1..6d3807a97 100644 --- a/src/Dodge/Item/Held/Rod.hs +++ b/src/Dodge/Item/Held/Rod.hs @@ -73,7 +73,7 @@ sniperRifle = & itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5} & itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun & itScope .~ ZoomScope (V2 0 0) 0 1 0.5 False - & itTargeting .~ targetLaser + & itUse . heldTargeting .~ (defaultTargeting & tgType .~ TargetLaser) & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1} machineGun :: Item diff --git a/src/Dodge/Item/Held/Utility.hs b/src/Dodge/Item/Held/Utility.hs index cbc574aec..581493c2a 100644 --- a/src/Dodge/Item/Held/Utility.hs +++ b/src/Dodge/Item/Held/Utility.hs @@ -44,7 +44,7 @@ torch = forceFieldGun :: Item forceFieldGun = defaultWeapon - & itTargeting .~ (targetRBPress & tgDraw .~ TargetDistanceDraw) + & itUse . heldTargeting .~ (defaultTargeting & tgType .~ TargetRBLine) & itParams .~ ParamMID Nothing & itUse . heldUse .~ HeldForceField --useForceFieldGun & itUse . heldDelay .~ NoDelay diff --git a/src/Dodge/Item/Targeting.hs b/src/Dodge/Item/Targeting.hs index 90cddeb14..645c014e9 100644 --- a/src/Dodge/Item/Targeting.hs +++ b/src/Dodge/Item/Targeting.hs @@ -1,37 +1,13 @@ module Dodge.Item.Targeting where -import Control.Lens import Dodge.Data.Item.Targeting defaultTargeting :: Targeting defaultTargeting = Targeting { _tgPos = Nothing - , _tgUpdate = NoTargetUpdate - , _tgDraw = NoTargetDraw + , _tgType = TargetRBPress + --, _tgDraw = NoTargetDraw , _tgID = Nothing , _tgActive = False } - -targetLaser :: Targeting -targetLaser = - defaultTargeting - & tgUpdate .~ TargetLaserUpdate - -targetRBPress :: Targeting -targetRBPress = - defaultTargeting - & tgUpdate .~ TargetRBPressUpdate - & tgDraw .~ SimpleDrawTarget - -targetRBCreature :: Targeting -targetRBCreature = - defaultTargeting - & tgUpdate .~ TargetRBCreatureUpdate - & tgDraw .~ TargetRBCreatureDraw - -targetCursor :: Targeting -targetCursor = - defaultTargeting - & tgUpdate .~ TargetCursorUpdate - & tgDraw .~ SimpleDrawTarget diff --git a/src/Dodge/Item/Weapon/ExtraEffect.hs b/src/Dodge/Item/Weapon/ExtraEffect.hs index eb70e90d6..2b82f443d 100644 --- a/src/Dodge/Item/Weapon/ExtraEffect.hs +++ b/src/Dodge/Item/Weapon/ExtraEffect.hs @@ -147,7 +147,7 @@ targetLaserUpdate _ cr w t , _lpDir = _crDir cr , _lpPos = sp , _lpColor = col - , _lpType = TargetLaser + , _lpType = TargetingLaser } --wpammo = _itConsumption it -- reloadFrac diff --git a/src/Dodge/Item/Weapon/Targeting.hs b/src/Dodge/Item/Weapon/Targeting.hs index bf8a38ddd..47cb91906 100644 --- a/src/Dodge/Item/Weapon/Targeting.hs +++ b/src/Dodge/Item/Weapon/Targeting.hs @@ -12,9 +12,9 @@ useTargetPos :: Creature -> World -> World -useTargetPos f cr w = case cr ^? crInv . ix (crSel cr) . itTargeting . tgPos of +useTargetPos f cr w = case cr ^? crInv . ix (crSel cr) . itUse . heldTargeting . tgPos of Nothing -> w Just p -> f p cr w removeItTarget :: Item -> Item -removeItTarget = itTargeting . tgPos .~ Nothing +removeItTarget = itUse . heldTargeting . tgPos .~ Nothing diff --git a/src/Dodge/Module.hs b/src/Dodge/Module.hs index 54d3f1c52..b75bebfda 100644 --- a/src/Dodge/Module.hs +++ b/src/Dodge/Module.hs @@ -29,9 +29,11 @@ moduleName imt = case imt of PENBUL -> Just "+PENETRATE" STATICBUL -> Just "+STATIC" CONCUSBUL -> Just "+CONCUSS" - TARGCR -> Just "+CREATURETARGETING" - TARGLAS -> Just "+LASERTARGETING" - TARGPOS -> Just "+POSTIONALTARGETING" + TARGET TargetRBCreature -> Just "+CREATURETARGETING" + TARGET TargetLaser -> Just "+LASERTARGETING" + TARGET TargetRBPress -> Just "+POSTIONALTARGETING" + TARGET TargetCursor -> Just "+CURSORTARGETING" + TARGET TargetRBLine -> Just "+LINETARGETING" MAGNETTRAJ -> Just "+MAGNETTRAJECTORY" FLECHETRAJ -> Just "+FLECHETTETRAJECTORY" BEZIERTRAJ -> Just "+BEZIERTRAJECTORY" diff --git a/src/Dodge/Projectile/Update.hs b/src/Dodge/Projectile/Update.hs index f9242822a..b4ecaa8db 100644 --- a/src/Dodge/Projectile/Update.hs +++ b/src/Dodge/Projectile/Update.hs @@ -139,7 +139,7 @@ pjTrack :: Int -> Proj -> World -> World pjTrack itid pj w = rotateToTarget pj w where rotateToTarget _ = fromMaybe id $ do - tpos <- w ^? itPoint . itTargeting . tgPos . _Just + tpos <- w ^? itPoint . itUse . heldTargeting . tgPos . _Just return $ cWorld . lWorld . projectiles . ix (_prjID pj) . prjSpin .~ turnToAmount diff --git a/src/Dodge/Render/ShapePicture.hs b/src/Dodge/Render/ShapePicture.hs index ff665e68b..ae79444e2 100644 --- a/src/Dodge/Render/ShapePicture.hs +++ b/src/Dodge/Render/ShapePicture.hs @@ -62,7 +62,7 @@ anyTargeting :: Configuration -> World -> SPic anyTargeting cfig w = (mempty, pictures $ IM.elems $ IM.mapMaybe f $ _crInv cr) where cr = you w - f it = fmap (\g -> drawTargeting g it cr cfig w) (it ^? itTargeting . tgDraw) + f it = fmap (\g -> drawTargeting g it cr cfig w) (it ^? itUse . heldTargeting . tgType) drawCreature :: Creature -> SPic drawCreature cr = case _crType cr of diff --git a/src/Dodge/Targeting.hs b/src/Dodge/Targeting.hs index 906da37f4..576513c8a 100644 --- a/src/Dodge/Targeting.hs +++ b/src/Dodge/Targeting.hs @@ -3,10 +3,10 @@ module Dodge.Targeting where import Dodge.Data.World import Dodge.Item.Weapon.ExtraEffect -updateTargeting :: TargetUpdate -> Item -> Creature -> World -> Targeting -> (World, Targeting) +updateTargeting :: TargetType -> Item -> Creature -> World -> Targeting -> (World, Targeting) updateTargeting tu = case tu of - NoTargetUpdate -> \_ _ w t -> (w, t) - TargetLaserUpdate -> targetLaserUpdate - TargetRBPressUpdate -> targetUpdateWith targetRBPressUpdate - TargetRBCreatureUpdate -> targetRBCreatureUp - TargetCursorUpdate -> targetUpdateWith targetCursorUpdate + TargetLaser -> targetLaserUpdate + TargetRBPress -> targetUpdateWith targetRBPressUpdate + TargetRBLine -> targetUpdateWith targetRBPressUpdate + TargetRBCreature -> targetRBCreatureUp + TargetCursor -> targetUpdateWith targetCursorUpdate diff --git a/src/Dodge/Targeting/Draw.hs b/src/Dodge/Targeting/Draw.hs index cfa274f82..8bf25a4fe 100644 --- a/src/Dodge/Targeting/Draw.hs +++ b/src/Dodge/Targeting/Draw.hs @@ -9,19 +9,21 @@ import LensHelp import Picture import ShortShow -drawTargeting :: TargetDraw -> Item -> Creature -> Configuration -> World -> Picture +drawTargeting :: TargetType -> Item -> Creature -> Configuration -> World -> Picture drawTargeting td = case td of - NoTargetDraw -> \_ _ _ _ -> mempty - SimpleDrawTarget -> targetSimpleDraw - TargetRBCreatureDraw -> targetRBCreatureDraw - TargetDistanceDraw -> targetDistanceDraw +-- NoTargetDraw -> \_ _ _ _ -> mempty + TargetRBCreature -> targetRBCreatureDraw + TargetRBLine -> targetDistanceDraw + TargetLaser -> \_ _ _ _ -> mempty + TargetRBPress -> targetSimpleDraw + TargetCursor -> targetSimpleDraw targetSimpleDraw :: Item -> Creature -> Configuration -> World -> Picture targetSimpleDraw = targetDraw $ const activeTargetCursorPic targetDistanceDraw :: Item -> Creature -> Configuration -> World -> Picture targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do - p <- itm ^? itTargeting . tgPos . _Just + p <- itm ^? itUse . heldTargeting . tgPos . _Just let p1 = worldPosToScreen cam p mwp = mouseWorldPos (w ^. input) (w ^. cWorld . camPos) p2 = worldPosToScreen cam mwp @@ -37,7 +39,7 @@ targetDistanceDraw itm _ cfig w = fromMaybe mempty $ do targetDraw :: (Item -> Picture) -> Item -> Creature -> Configuration -> World -> Picture targetDraw f it _ cfig w = fromMaybe mempty $ do - p <- it ^? itTargeting . tgPos . _Just + p <- it ^? itUse . heldTargeting . tgPos . _Just return $ winScale cfig $ setLayer FixedCoordLayer $ @@ -65,7 +67,7 @@ targetRBCreatureDraw :: Item -> Creature -> Configuration -> World -> Picture targetRBCreatureDraw = targetDraw thepic where thepic it - | _tgActive $ _itTargeting it = activeTargetCursorPic + | _tgActive $ _heldTargeting $ _itUse it = activeTargetCursorPic | otherwise = targetCursorPic targCorner :: Picture