Refactor crPos to be a V3
This commit is contained in:
+20
-19
@@ -8,6 +8,7 @@ module Dodge.HeldUse (
|
||||
heldEffectMuzzles,
|
||||
) where
|
||||
|
||||
import Linear (_xy)
|
||||
import Color
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
@@ -72,7 +73,7 @@ hammerCheck f pt loc cr w = case itemTriggerType loc of
|
||||
w & setwarming
|
||||
& soundContinue
|
||||
(CrWeaponSound cid 0)
|
||||
(_crPos cr)
|
||||
(cr ^. crPos . _xy)
|
||||
(warmupSound $ it ^. itType)
|
||||
(Just 2)
|
||||
& itmset . itParams . wTime +~ 1
|
||||
@@ -82,7 +83,7 @@ hammerCheck f pt loc cr w = case itemTriggerType loc of
|
||||
w & setwarming
|
||||
& soundContinue
|
||||
(CrWeaponSound cid 0)
|
||||
(_crPos cr)
|
||||
(cr ^. crPos . _xy)
|
||||
(warmupSound $ it ^. itType)
|
||||
(Just 2)
|
||||
& itmset . itParams . wTime +~ 1
|
||||
@@ -371,8 +372,8 @@ applyCME loc cr cme
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
spush = maybe 0 itemSidePush $ itm ^? itType . ibtHeld
|
||||
failsound w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
Just 0 -> soundStart (CrWeaponFailSound (_crID cr)) (_crPos cr) click1S Nothing w
|
||||
_ -> soundContinue (CrWeaponFailSound (_crID cr)) (_crPos cr) click1S Nothing w
|
||||
Just 0 -> soundStart (CrWeaponFailSound (_crID cr)) (cr ^. crPos . _xy) click1S Nothing w
|
||||
_ -> soundContinue (CrWeaponFailSound (_crID cr)) (cr ^. crPos . _xy) click1S Nothing w
|
||||
|
||||
itemSidePush :: HeldItemType -> Float
|
||||
itemSidePush = \case
|
||||
@@ -443,14 +444,14 @@ applySoundCME itm cr = fromMaybe id $ do
|
||||
(soundid, x) <- bgunSound itm
|
||||
return $
|
||||
if x > 0
|
||||
then soundContinue (CrWeaponSound cid 0) (_crPos cr) soundid (Just x)
|
||||
else soundMultiFrom [CrWeaponSound cid j | j <- [0 .. 16]] (_crPos cr) soundid Nothing
|
||||
then soundContinue (CrWeaponSound cid 0) (cr ^. crPos . _xy) soundid (Just x)
|
||||
else soundMultiFrom [CrWeaponSound cid j | j <- [0 .. 16]] (cr ^. crPos . _xy) soundid Nothing
|
||||
where
|
||||
cid = _crID cr
|
||||
|
||||
applyRecoil :: LocationDT OItem -> Creature -> World -> World
|
||||
applyRecoil loc cr =
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crPos
|
||||
cWorld . lWorld . creatures . ix (_crID cr) . crPos . _xy
|
||||
+~ rotateV (_crDir cr + Q.qToAng q) (V2 ((- recoilAmount itm) / crMass (_crType cr)) 0)
|
||||
where
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
@@ -552,7 +553,7 @@ applySidePush :: Float -> Creature -> World -> World
|
||||
applySidePush 0 _ w = w
|
||||
applySidePush maxSide cr w =
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix cid . crPos +~ push
|
||||
& cWorld . lWorld . creatures . ix cid . crPos . _xy +~ push
|
||||
& randGen .~ g
|
||||
where
|
||||
cid = _crID cr
|
||||
@@ -664,7 +665,7 @@ makeMuzzleFlare mz loc cr = case mz ^. mzFlareType of
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`Q.comp` (_mzPos mz `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
pos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
pos = (cr ^. crPos . _xy) + rotateV (_crDir cr) (V2 x y)
|
||||
dir = _crDir cr + Q.qToAng q
|
||||
oddcheck f w
|
||||
| odd (w ^. cWorld . lWorld . lClock) = f w
|
||||
@@ -796,7 +797,7 @@ shootTractorBeam cr w =
|
||||
w & cWorld . lWorld . tractorBeams .:~ tractorBeamAt spos outpos dir power
|
||||
& soundContinue (CrWeaponSound (_crID cr) 0) cpos tone440sawtoothquietS (Just 2)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
cpos = cr ^. crPos . _xy
|
||||
spos = cpos +.+ (crRad (cr ^. crType) + 10) *.* unitVectorAtAngle dir
|
||||
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
|
||||
dir = _crDir cr
|
||||
@@ -827,7 +828,7 @@ creatureShootLaser loc cr mz w =
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
pos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
pos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
|
||||
dir = _crDir cr + Q.qToAng q + a
|
||||
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||
inacc = _mzInaccuracy mz
|
||||
@@ -868,7 +869,7 @@ creatureShootPulseLaser loc cr mz w =
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
pos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
pos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
|
||||
dir = _crDir cr + Q.qToAng q + a
|
||||
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||
inacc = _mzInaccuracy mz
|
||||
@@ -895,7 +896,7 @@ creatureShootPulseBall loc cr mz w = w & randGen .~ g & shootPulseBall pos dir
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
pos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
pos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
|
||||
dir = _crDir cr + Q.qToAng q + a
|
||||
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||
inacc = _mzInaccuracy mz
|
||||
@@ -991,7 +992,7 @@ shootBullet bu loc cr mz w = makeBullet bu itm bulpos dir . (randGen .~ g) $ w
|
||||
locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
bulpos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
bulpos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
|
||||
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||
dir = _crDir cr + Q.qToAng q + a
|
||||
inacc = _mzInaccuracy mz
|
||||
@@ -1130,7 +1131,7 @@ useGasParams (NInt magitid) mz loc cr w =
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
pos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
pos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
|
||||
(a, g') = randomR (- inacc, inacc) g
|
||||
inacc = _mzInaccuracy mz
|
||||
offset = case mz ^. mzRandomOffset of
|
||||
@@ -1219,7 +1220,7 @@ shootTeslaArc loc cr mz w =
|
||||
(V3 x y _, q) =
|
||||
locOrient loc cr
|
||||
`Q.comp` ((_mzPos mz + V2 0 offset) `v2z` 0, Q.axisAngle (V3 0 0 1) (_mzRot mz))
|
||||
pos = _crPos cr + rotateV (_crDir cr) (V2 x y)
|
||||
pos = cr ^. crPos . _xy + rotateV (_crDir cr) (V2 x y)
|
||||
dir = _crDir cr + Q.qToAng q
|
||||
offset = case mz ^. mzRandomOffset of
|
||||
0 -> 0
|
||||
@@ -1343,12 +1344,12 @@ createProjectile x pjtype mtree stab muz cr w = fromMaybe (failsound w) $ do
|
||||
makesound =
|
||||
soundMultiFrom
|
||||
[CrWeaponSound (_crID cr) j | j <- [0 .. 3]]
|
||||
(_crPos cr)
|
||||
(cr ^. crPos . _xy)
|
||||
tap4S
|
||||
Nothing
|
||||
failsound w' = case w' ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w'
|
||||
_ -> soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w'
|
||||
Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (cr ^. crPos . _xy) click1S Nothing w'
|
||||
_ -> soundContinue (CrWeaponSound (_crID cr) 0) (cr ^. crPos . _xy) click1S Nothing w'
|
||||
|
||||
---- need to add these to muzzle flare?
|
||||
--makeMuzzleSmoke :: Muzzle -> Item -> Creature -> World -> World
|
||||
|
||||
Reference in New Issue
Block a user