Make bezierGun set target on right click

This commit is contained in:
2021-05-23 20:32:15 +02:00
parent b337fbdab9
commit 3ae454acf4
7 changed files with 76 additions and 19 deletions
+17
View File
@@ -8,6 +8,7 @@ import Dodge.Data
import Dodge.Base
import Dodge.Item.Weapon.Decoration
import Dodge.Item.Weapon.UseEffect
import Dodge.Item.Attachment.Data
import Dodge.WorldEvent.Flash
import Dodge.WorldEvent.ThingsHit
import Picture
@@ -16,6 +17,8 @@ import Geometry.Vector
import Data.Maybe
import Control.Lens
import qualified Data.IntMap.Strict as IM
import qualified Data.Set as S
import qualified SDL
{- |
Controls resetting a weapon, allows for non-continuous fire needing a button release. -}
wpRecock :: ItEffect
@@ -98,3 +101,17 @@ autoSonarEffect = ItInvEffect {_itInvEffect = f 50 ,_itEffectCounter = 0 }
. itEffect . itInvEffect .~ f 140
f t cr i w = w & creatures . ix (_crID cr) . crInv . ix i
. itEffect . itInvEffect .~ f (t-1)
bezierTargetEffect :: ItEffect
bezierTargetEffect = ItInvEffect
{_itInvEffect = setBezierTarget
,_itEffectCounter = 0
}
setBezierTarget :: Creature -> Int -> World -> World
setBezierTarget cr invid w
| _crInvSel cr /= invid = w
| SDL.ButtonRight `S.member` _mouseButtons w = w
& creatures . ix (_crID cr) . crInv . ix invid . itAttachment
%~ maybe (Just $ ItTargetPos $ mouseWorldPos w) Just
| otherwise = w & creatures . ix (_crID cr) . crInv . ix invid . itAttachment .~ Nothing