Remove targeting bugs
This commit is contained in:
@@ -18,7 +18,7 @@ moduleModification imt = case imt of
|
|||||||
PENBUL -> itUse . heldConsumption . laAmmoType . amBullet . buEffect .~ PenetrateBullet
|
PENBUL -> itUse . heldConsumption . laAmmoType . amBullet . buEffect .~ PenetrateBullet
|
||||||
STATICBUL -> itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ BulBall TeslaBall
|
STATICBUL -> itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ BulBall TeslaBall
|
||||||
CONCUSBUL -> itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ BulBall ConcBall
|
CONCUSBUL -> itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ BulBall ConcBall
|
||||||
TARGET t -> itUse . useTargeting .~ (Just t)
|
TARGET t -> itUse . useTargeting ?~ t
|
||||||
MAGNETTRAJ ->
|
MAGNETTRAJ ->
|
||||||
(itUse . heldConsumption . laAmmoType . amBullet . buTrajectory .~ MagnetTrajectory 0)
|
(itUse . heldConsumption . laAmmoType . amBullet . buTrajectory .~ MagnetTrajectory 0)
|
||||||
. (itUse . heldConsumption . laAmmoType . amBullet . buVel .~ V2 10 0)
|
. (itUse . heldConsumption . laAmmoType . amBullet . buVel .~ V2 10 0)
|
||||||
@@ -36,7 +36,7 @@ moduleModification imt = case imt of
|
|||||||
where
|
where
|
||||||
makeDirectedTele it =
|
makeDirectedTele it =
|
||||||
it
|
it
|
||||||
& itUse . useTargeting .~ (Just TargetRBPress)
|
& itUse . useTargeting ?~ TargetRBPress
|
||||||
& itUse . heldMods %~ ModWithDirectedTeleport -- .:~ withPosDirWallCheck directedTelPos
|
& itUse . heldMods %~ ModWithDirectedTeleport -- .:~ 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 . heldAim . aimZoom . izFac .~ 1
|
& itUse . heldAim . aimZoom . izFac .~ 1
|
||||||
|
|||||||
@@ -235,10 +235,10 @@ equipmentEffects cr = flip (foldl' $ flip $ useEquipment cr) (IM.keys $ _crInvEq
|
|||||||
-- a loop going over all inventory items
|
-- a loop going over all inventory items
|
||||||
invSideEff :: Creature -> World -> World
|
invSideEff :: Creature -> World -> World
|
||||||
invSideEff cr w =
|
invSideEff cr w =
|
||||||
crDoTargeting cr $
|
updateTargeting (crGetTargeting cr) cr $
|
||||||
weaponReloadSounds cr $
|
weaponReloadSounds cr $
|
||||||
over (cWorld . lWorld . creatures . ix (_crID cr)) crSetTargeting $
|
|
||||||
IM.foldl' f w (_crInv cr)
|
IM.foldl' f w (_crInv cr)
|
||||||
|
-- be careful with side effects that affect creature targeting
|
||||||
where
|
where
|
||||||
f w' it =
|
f w' it =
|
||||||
itemInvSideEffect cr it $
|
itemInvSideEffect cr it $
|
||||||
@@ -275,11 +275,10 @@ updateAutoRecharge it = case it ^? itUse . leftConsumption of
|
|||||||
| l < m -> it & itUse . leftConsumption . arProgress -~ 1
|
| l < m -> it & itUse . leftConsumption . arProgress -~ 1
|
||||||
_ -> it
|
_ -> it
|
||||||
|
|
||||||
crSetTargeting :: Creature -> Creature
|
crGetTargeting :: Creature -> Maybe TargetType
|
||||||
crSetTargeting cr = fromMaybe cr $ do
|
crGetTargeting cr = do
|
||||||
itm <- find hastargeting $ helditem ++ IM.elems (getCrEquipment cr)
|
itm <- find hastargeting $ helditem ++ IM.elems (getCrEquipment cr)
|
||||||
tt <- itm ^? itUse . useTargeting . _Just
|
itm ^? itUse . useTargeting . _Just
|
||||||
return $ cr & crTargeting . ctType ?~ tt
|
|
||||||
where
|
where
|
||||||
hastargeting itm = isJust (itm ^? itUse . useTargeting . _Just)
|
hastargeting itm = isJust (itm ^? itUse . useTargeting . _Just)
|
||||||
helditem = fromMaybe [] $ do
|
helditem = fromMaybe [] $ do
|
||||||
@@ -287,16 +286,6 @@ crSetTargeting cr = fromMaybe cr $ do
|
|||||||
itm <- cr ^? crInv . ix i
|
itm <- cr ^? crInv . ix i
|
||||||
return [itm]
|
return [itm]
|
||||||
|
|
||||||
crDoTargeting :: Creature -> World -> World
|
|
||||||
crDoTargeting cr = fromMaybe id $ do
|
|
||||||
tt <- cr ^? crTargeting . ctType . _Just
|
|
||||||
return $ updateTargeting tt cr
|
|
||||||
|
|
||||||
doItemTargeting :: Int -> Creature -> World -> World
|
|
||||||
doItemTargeting invid cr w = case cr ^? crInv . ix invid . itUse . useTargeting . _Just of
|
|
||||||
Nothing -> w
|
|
||||||
Just t -> updateTargeting t cr w
|
|
||||||
|
|
||||||
weaponReloadSounds :: Creature -> World -> World
|
weaponReloadSounds :: Creature -> World -> World
|
||||||
weaponReloadSounds cr w = case cr ^? crInvSel . iselAction of
|
weaponReloadSounds cr w = case cr ^? crInvSel . iselAction of
|
||||||
Just ReloadAction{_reloadAction = la} ->
|
Just ReloadAction{_reloadAction = la} ->
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
{-# LANGUAGE DeriveGeneric #-}
|
|
||||||
{-# LANGUAGE DeriveAnyClass #-}
|
{-# LANGUAGE DeriveAnyClass #-}
|
||||||
|
{-# LANGUAGE DeriveGeneric #-}
|
||||||
{-# LANGUAGE StrictData #-}
|
{-# LANGUAGE StrictData #-}
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
|
||||||
module Dodge.Data.Item.Targeting where
|
module Dodge.Data.Item.Targeting where
|
||||||
|
|
||||||
import Control.Lens
|
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import Data.Aeson.TH
|
import Data.Aeson.TH
|
||||||
import Geometry.Data
|
|
||||||
|
|
||||||
data TargetType
|
data TargetType
|
||||||
= TargetLaser
|
= TargetLaser
|
||||||
|
|||||||
@@ -346,7 +346,7 @@ useMod hm = case hm of
|
|||||||
yoff x = fromIntegral x - fromIntegral (n' -1) / 2
|
yoff x = fromIntegral x - fromIntegral (n' -1) / 2
|
||||||
n' = _lasCycle (_itParams it)
|
n' = _lasCycle (_itParams it)
|
||||||
thegapDualBeam = _dbGap . _itParams
|
thegapDualBeam = _dbGap . _itParams
|
||||||
directedTelPos it cr w = (p, a)
|
directedTelPos _ cr w = (p, a)
|
||||||
where
|
where
|
||||||
p = fromMaybe (_crPos cr) $ cr ^? crTargeting . ctPos . _Just
|
p = fromMaybe (_crPos cr) $ cr ^? crTargeting . ctPos . _Just
|
||||||
a = argV (mouseWorldPos (w ^. input) (w ^. cWorld . camPos) -.- p)
|
a = argV (mouseWorldPos (w ^. input) (w ^. cWorld . camPos) -.- p)
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ targetingHat tt =
|
|||||||
defaultEquipment
|
defaultEquipment
|
||||||
& itUse . equipEffect . eeSite .~ GoesOnHead
|
& itUse . equipEffect . eeSite .~ GoesOnHead
|
||||||
& itType . iyBase .~ EQUIP (TARGETINGHAT tt)
|
& itType . iyBase .~ EQUIP (TARGETINGHAT tt)
|
||||||
& itUse . useTargeting .~ (Just tt)
|
& itUse . useTargeting ?~ tt
|
||||||
|
|
||||||
headLamp :: Item
|
headLamp :: Item
|
||||||
headLamp =
|
headLamp =
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ sniperRifle =
|
|||||||
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5}
|
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5}
|
||||||
& itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun
|
& itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun
|
||||||
& itScope .~ ZoomScope (V2 0 0) 0 1 0.5 False
|
& itScope .~ ZoomScope (V2 0 0) 0 1 0.5 False
|
||||||
& itUse . useTargeting .~ (Just TargetLaser)
|
& itUse . useTargeting ?~ TargetLaser
|
||||||
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
|
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
|
||||||
|
|
||||||
machineGun :: Item
|
machineGun :: Item
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ torch =
|
|||||||
forceFieldGun :: Item
|
forceFieldGun :: Item
|
||||||
forceFieldGun =
|
forceFieldGun =
|
||||||
defaultWeapon
|
defaultWeapon
|
||||||
& itUse . useTargeting .~ Just TargetRBLine
|
& itUse . useTargeting ?~ TargetRBLine
|
||||||
& itParams .~ ParamMID Nothing
|
& itParams .~ ParamMID Nothing
|
||||||
& itUse . heldUse .~ HeldForceField --useForceFieldGun
|
& itUse . heldUse .~ HeldForceField --useForceFieldGun
|
||||||
& itUse . heldDelay .~ NoDelay
|
& itUse . heldDelay .~ NoDelay
|
||||||
|
|||||||
+25
-9
@@ -1,4 +1,6 @@
|
|||||||
module Dodge.Targeting where
|
module Dodge.Targeting (
|
||||||
|
updateTargeting,
|
||||||
|
) where
|
||||||
|
|
||||||
import Color
|
import Color
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
@@ -14,13 +16,20 @@ import Geometry.Vector
|
|||||||
import LensHelp
|
import LensHelp
|
||||||
import qualified SDL
|
import qualified SDL
|
||||||
|
|
||||||
updateTargeting :: TargetType -> Creature -> World -> World
|
updateTargeting :: Maybe TargetType -> Creature -> World -> World
|
||||||
updateTargeting tu = case tu of
|
updateTargeting tu = case tu of
|
||||||
TargetLaser -> targetLaserUpdate'
|
Nothing -> clearTargeting
|
||||||
TargetRBPress -> upCT (flip targetRBPressUpdate . _crTargeting)
|
Just TargetLaser -> targetLaserUpdate'
|
||||||
TargetRBLine -> upCT (flip targetRBPressUpdate . _crTargeting)
|
Just TargetRBPress -> upCT (flip targetRBPressUpdate . _crTargeting)
|
||||||
TargetRBCreature -> upCT targetRBCreatureUp
|
Just TargetRBLine -> upCT (flip targetRBPressUpdate . _crTargeting)
|
||||||
TargetCursor -> upCT (flip targetCursorUpdate . _crTargeting)
|
Just TargetRBCreature -> upCT targetRBCreatureUp
|
||||||
|
Just TargetCursor -> upCT (flip targetCursorUpdate . _crTargeting)
|
||||||
|
|
||||||
|
clearTargeting :: Creature -> World -> World
|
||||||
|
clearTargeting cr = cWorld . lWorld . creatures . ix (_crID cr) . crTargeting .~ defaultTargeting
|
||||||
|
|
||||||
|
defaultTargeting :: CreatureTargeting
|
||||||
|
defaultTargeting = CreatureTargeting Nothing Nothing Nothing False
|
||||||
|
|
||||||
upCT :: (Creature -> World -> CreatureTargeting) -> Creature -> World -> World
|
upCT :: (Creature -> World -> CreatureTargeting) -> Creature -> World -> World
|
||||||
upCT f cr w = w & cWorld . lWorld . creatures . ix (_crID cr) . crTargeting .~ f cr w
|
upCT f cr w = w & cWorld . lWorld . creatures . ix (_crID cr) . crTargeting .~ f cr w
|
||||||
@@ -29,8 +38,10 @@ targetRBCreatureUp :: Creature -> World -> CreatureTargeting
|
|||||||
targetRBCreatureUp cr w
|
targetRBCreatureUp cr w
|
||||||
| SDL.ButtonRight `M.member` _mouseButtons (_input w) && isJust (t ^? ctID . _Just)
|
| SDL.ButtonRight `M.member` _mouseButtons (_input w) && isJust (t ^? ctID . _Just)
|
||||||
&& canSeeTarget =
|
&& canSeeTarget =
|
||||||
(t & updatePos & ctActive .~ True)
|
t & updatePos & ctActive .~ True
|
||||||
|
& ctType ?~ TargetRBCreature
|
||||||
| otherwise = t & ctID .~ fmap _crID newtarg & updatePos & ctActive .~ False
|
| otherwise = t & ctID .~ fmap _crID newtarg & updatePos & ctActive .~ False
|
||||||
|
& ctType ?~ TargetRBCreature
|
||||||
where
|
where
|
||||||
t = _crTargeting cr
|
t = _crTargeting cr
|
||||||
newtarg =
|
newtarg =
|
||||||
@@ -52,6 +63,7 @@ targetCursorUpdate w ct =
|
|||||||
ct
|
ct
|
||||||
& ctPos . _Just .~ mouseWorldPos (w ^. input) (w ^. cWorld . camPos)
|
& ctPos . _Just .~ mouseWorldPos (w ^. input) (w ^. cWorld . camPos)
|
||||||
& ctActive .~ True
|
& ctActive .~ True
|
||||||
|
& ctType ?~ TargetCursor
|
||||||
|
|
||||||
targetRBPressUpdate :: World -> CreatureTargeting -> CreatureTargeting
|
targetRBPressUpdate :: World -> CreatureTargeting -> CreatureTargeting
|
||||||
targetRBPressUpdate w t
|
targetRBPressUpdate w t
|
||||||
@@ -59,13 +71,16 @@ targetRBPressUpdate w t
|
|||||||
t
|
t
|
||||||
& ctPos %~ maybe (Just $ mouseWorldPos (w ^. input) (w ^. cWorld . camPos)) Just
|
& ctPos %~ maybe (Just $ mouseWorldPos (w ^. input) (w ^. cWorld . camPos)) Just
|
||||||
& ctActive .~ True
|
& ctActive .~ True
|
||||||
|
& ctType ?~ TargetRBPress
|
||||||
| otherwise =
|
| otherwise =
|
||||||
t
|
t
|
||||||
& ctPos %~ const Nothing
|
& ctPos %~ const Nothing
|
||||||
& ctActive .~ False
|
& ctActive .~ False
|
||||||
|
& ctType ?~ TargetRBPress
|
||||||
|
|
||||||
targetLaserUpdate' :: Creature -> World -> World
|
targetLaserUpdate' :: Creature -> World -> World
|
||||||
targetLaserUpdate' cr w = let (w', ct') = targetLaserUpdate cr w (_crTargeting cr)
|
targetLaserUpdate' cr w =
|
||||||
|
let (w', ct') = targetLaserUpdate cr w (_crTargeting cr)
|
||||||
in w' & cWorld . lWorld . creatures . ix (_crID cr) . crTargeting .~ ct'
|
in w' & cWorld . lWorld . creatures . ix (_crID cr) . crTargeting .~ ct'
|
||||||
|
|
||||||
targetLaserUpdate :: Creature -> World -> CreatureTargeting -> (World, CreatureTargeting)
|
targetLaserUpdate :: Creature -> World -> CreatureTargeting -> (World, CreatureTargeting)
|
||||||
@@ -75,6 +90,7 @@ targetLaserUpdate cr w t
|
|||||||
, t
|
, t
|
||||||
& ctPos .~ fmap fst mp
|
& ctPos .~ fmap fst mp
|
||||||
& ctActive .~ True
|
& ctActive .~ True
|
||||||
|
& ctType ?~ TargetLaser
|
||||||
)
|
)
|
||||||
| otherwise =
|
| otherwise =
|
||||||
( w
|
( w
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
module Dodge.Targeting.Draw where
|
module Dodge.Targeting.Draw (
|
||||||
|
drawTargeting,
|
||||||
|
) where
|
||||||
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Base
|
import Dodge.Base
|
||||||
@@ -13,12 +15,12 @@ drawTargeting :: TargetType -> Creature -> Configuration -> World -> Picture
|
|||||||
drawTargeting td = case td of
|
drawTargeting td = case td of
|
||||||
TargetRBCreature -> targetRBCreatureDraw
|
TargetRBCreature -> targetRBCreatureDraw
|
||||||
TargetRBLine -> targetDistanceDraw
|
TargetRBLine -> targetDistanceDraw
|
||||||
TargetLaser -> \_ _ _ -> mempty
|
TargetLaser -> targetSimpleDraw
|
||||||
TargetRBPress -> targetSimpleDraw
|
TargetRBPress -> targetSimpleDraw
|
||||||
TargetCursor -> targetSimpleDraw
|
TargetCursor -> targetSimpleDraw
|
||||||
|
|
||||||
targetSimpleDraw :: Creature -> Configuration -> World -> Picture
|
targetSimpleDraw :: Creature -> Configuration -> World -> Picture
|
||||||
targetSimpleDraw = targetDraw $ activeTargetCursorPic
|
targetSimpleDraw = targetDraw activeTargetCursorPic
|
||||||
|
|
||||||
targetDistanceDraw :: Creature -> Configuration -> World -> Picture
|
targetDistanceDraw :: Creature -> Configuration -> World -> Picture
|
||||||
targetDistanceDraw cr cfig w = fromMaybe mempty $ do
|
targetDistanceDraw cr cfig w = fromMaybe mempty $ do
|
||||||
@@ -43,8 +45,7 @@ targetDraw f cr cfig w = fromMaybe mempty $ do
|
|||||||
winScale cfig $
|
winScale cfig $
|
||||||
setLayer FixedCoordLayer $
|
setLayer FixedCoordLayer $
|
||||||
color white $
|
color white $
|
||||||
uncurryV translate (worldPosToScreen cam p) $
|
uncurryV translate (worldPosToScreen cam p) f
|
||||||
f
|
|
||||||
where
|
where
|
||||||
cam = w ^. cWorld . camPos
|
cam = w ^. cWorld . camPos
|
||||||
|
|
||||||
@@ -66,20 +67,14 @@ targetRBCreatureDraw :: Creature -> Configuration -> World -> Picture
|
|||||||
targetRBCreatureDraw cr = targetDraw thepic cr
|
targetRBCreatureDraw cr = targetDraw thepic cr
|
||||||
where
|
where
|
||||||
thepic
|
thepic
|
||||||
| _ctActive $ _crTargeting $ cr = activeTargetCursorPic
|
| _ctActive $ _crTargeting cr = activeTargetCursorPic
|
||||||
| otherwise = targetCursorPic
|
| otherwise = targetCursorPic
|
||||||
|
|
||||||
targCorner :: Picture
|
targCorner :: Picture
|
||||||
targCorner =
|
targCorner = line [V2 (x - y) x, V2 x x, V2 x (x - y)]
|
||||||
pictures
|
|
||||||
[ line [V2 x x, V2 x (x - y)]
|
|
||||||
, line [V2 x x, V2 (x - y) x]
|
|
||||||
]
|
|
||||||
where
|
where
|
||||||
x = 10
|
x = 10
|
||||||
y = 5
|
y = 5
|
||||||
|
|
||||||
targetCursorPic :: Picture
|
targetCursorPic :: Picture
|
||||||
targetCursorPic =
|
targetCursorPic = pictures [rotate a targCorner | a <- [0, 0.5 * pi, pi, 1.5 * pi]]
|
||||||
pictures
|
|
||||||
[rotate a targCorner | a <- [0, 0.5 * pi, pi, 1.5 * pi]]
|
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
{-# LANGUAGE BangPatterns #-}
|
--{-# LANGUAGE BangPatterns #-}
|
||||||
|
|
||||||
{- |
|
{- |
|
||||||
Module : Dodge.Update
|
Module : Dodge.Update
|
||||||
@@ -653,7 +653,7 @@ updateSeenWalls :: World -> World
|
|||||||
updateSeenWalls w = foldl' markWallSeen w (map (_wlID . snd) $ allVisibleWalls w)
|
updateSeenWalls w = foldl' markWallSeen w (map (_wlID . snd) $ allVisibleWalls w)
|
||||||
|
|
||||||
markWallSeen :: World -> Int -> World
|
markWallSeen :: World -> Int -> World
|
||||||
markWallSeen w i = w & cWorld . seenWalls . at i .~ Just ()
|
markWallSeen w i = w & cWorld . seenWalls . at i ?~ ()
|
||||||
--markWallSeen !w !i = w & cWorld . lWorld . walls %~ IM.adjust markSeen i
|
--markWallSeen !w !i = w & cWorld . lWorld . walls %~ IM.adjust markSeen i
|
||||||
-- in the past there might have been a space leak, which the following was meant
|
-- in the past there might have been a space leak, which the following was meant
|
||||||
-- to fix
|
-- to fix
|
||||||
|
|||||||
Reference in New Issue
Block a user