This commit is contained in:
2022-12-31 23:01:54 +00:00
parent 0dc9a09723
commit 8838d1120b
6 changed files with 54 additions and 71 deletions
+19 -1
View File
@@ -1,5 +1,7 @@
module Dodge.HeldUse where
import Dodge.Wall.Move
import Dodge.Wall.ForceField
import Color
import Data.Maybe
import Data.Traversable
@@ -13,7 +15,6 @@ import Dodge.Item.Weapon.Launcher
import Dodge.Item.Weapon.Radar
import Dodge.Item.Weapon.Shatter
import Dodge.Item.Weapon.TriggerType
import Dodge.Item.Weapon.Utility
import Dodge.Projectile.Create
import Dodge.SoundLogic
import Dodge.Tesla.Arc
@@ -504,3 +505,20 @@ shootTeslaArc it cr w =
(w', ip) = makeTeslaArc (_itParams it) pos dir w
pos = _crPos cr +.+ aimingMuzzlePos cr it *.* unitVectorAtAngle dir
dir = _crDir cr
-- I believe because the targeting returns to nothing straight after you release
-- the rmb, it is possible for this to do nothing
-- TODO investigate more and fix
useForceFieldGun :: Item -> Creature -> World -> World
useForceFieldGun itm cr w = fromMaybe w $ do
a <- _tgPos $ _itTargeting 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)
return $
w
& cWorld . lWorld . walls %~ IM.insertWith (\_ x -> x) i forceField{_wlID = i}
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix (_ipInvID (_itLocation itm)) . itParams . paramMID ?~ i
& moveWallIDUnsafe i wlline
where
i = fromMaybe (IM.newKey (_walls (_lWorld (_cWorld w)))) $ itm ^? itParams . paramMID . _Just