Cleanup old muzzle position code
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
module Dodge.Creature.HandPos (
|
module Dodge.Creature.HandPos (
|
||||||
aimingWeaponZeroPos,
|
-- aimingWeaponZeroPos,
|
||||||
aimingMuzzlePos,
|
|
||||||
aimingMuzzleLength,
|
|
||||||
translatePointToLeftHand,
|
translatePointToLeftHand,
|
||||||
translatePointToRightHand,
|
translatePointToRightHand,
|
||||||
translatePointToHead,
|
translatePointToHead,
|
||||||
@@ -21,30 +19,8 @@ import Data.Maybe
|
|||||||
import Dodge.Creature.Test
|
import Dodge.Creature.Test
|
||||||
import Dodge.Data.Creature
|
import Dodge.Data.Creature
|
||||||
import Geometry
|
import Geometry
|
||||||
import Linear
|
|
||||||
import ShapePicture
|
import ShapePicture
|
||||||
|
|
||||||
-- the position of a weapon handle
|
|
||||||
aimingWeaponHandlePos :: Creature -> Item -> Point2
|
|
||||||
aimingWeaponHandlePos _ it = case it ^? itUse . heldAim . aimStance of
|
|
||||||
Just TwoHandUnder -> V2 (-2) 0
|
|
||||||
Just TwoHandOver -> V2 (-7) 0
|
|
||||||
Just OneHand -> V2 10 (-2)
|
|
||||||
Just TwoHandFlat -> V2 10 0
|
|
||||||
Nothing -> 0
|
|
||||||
|
|
||||||
aimingWeaponZeroPos :: Creature -> Item -> Point2
|
|
||||||
aimingWeaponZeroPos cr it =
|
|
||||||
aimingWeaponHandlePos cr it
|
|
||||||
- fromMaybe 0 (it ^? itUse . heldAim . aimHandlePos)
|
|
||||||
|
|
||||||
aimingMuzzlePos :: Creature -> Item -> [Point2]
|
|
||||||
aimingMuzzlePos cr it = fmap ((+ zp) . _mzPos) (it ^.. itUse . heldAim . aimMuzzles . folded)
|
|
||||||
where
|
|
||||||
zp = aimingWeaponZeroPos cr it
|
|
||||||
|
|
||||||
aimingMuzzleLength :: Creature -> Item -> Float
|
|
||||||
aimingMuzzleLength cr it = head (aimingMuzzlePos cr it) ^. _x
|
|
||||||
|
|
||||||
translatePointToRightHand :: Creature -> Point3 -> Point3
|
translatePointToRightHand :: Creature -> Point3 -> Point3
|
||||||
translatePointToRightHand cr = translatePointToRightHand' cr . mirrorV3xz
|
translatePointToRightHand cr = translatePointToRightHand' cr . mirrorV3xz
|
||||||
|
|||||||
+17
-11
@@ -164,8 +164,9 @@ makeMuzzleFlare mz itmtree cr = case mz ^. mzFlareType of
|
|||||||
-- .:~ tlsTimeRadColPos 1 100 (V3 0 0 1) (pos `v2z` 10)
|
-- .:~ tlsTimeRadColPos 1 100 (V3 0 0 1) (pos `v2z` 10)
|
||||||
where
|
where
|
||||||
itm = itmtree ^. ldtValue
|
itm = itmtree ^. ldtValue
|
||||||
pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
|
(moff,mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
|
||||||
dir = _crDir cr + _mzRot mz
|
pos = _crPos cr + rotateV (_crDir cr) moff
|
||||||
|
dir = _crDir cr + mrot
|
||||||
|
|
||||||
--{-# OPTIONS -Wno-incomplete-uni-patterns #-}
|
--{-# OPTIONS -Wno-incomplete-uni-patterns #-}
|
||||||
muzFlareAt :: Color -> Point3 -> Float -> World -> World
|
muzFlareAt :: Color -> Point3 -> Float -> World -> World
|
||||||
@@ -295,10 +296,11 @@ shootLaser itmtree cr mz w =
|
|||||||
}
|
}
|
||||||
where
|
where
|
||||||
itm = itmtree ^. ldtValue
|
itm = itmtree ^. ldtValue
|
||||||
pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
|
(moff,mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
|
||||||
|
pos = _crPos cr + rotateV (_crDir cr) moff
|
||||||
|
dir = _crDir cr + mrot + a
|
||||||
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
(a, g) = randomR (- inacc, inacc) $ _randGen w
|
||||||
inacc = _mzInaccuracy mz
|
inacc = _mzInaccuracy mz
|
||||||
dir = _crDir cr + _mzRot mz + a
|
|
||||||
|
|
||||||
lasRayAt :: Color -> Int -> Float -> Point2 -> Float -> LaserStart
|
lasRayAt :: Color -> Int -> Float -> Point2 -> Float -> LaserStart
|
||||||
lasRayAt col dam phasev pos dir =
|
lasRayAt col dam phasev pos dir =
|
||||||
@@ -363,7 +365,10 @@ getBulletTrajectory mz itm bt tp cr w = case bt of
|
|||||||
BezierTrajectoryType -> BezierTrajectory bulpos tp (mouseWorldPos (w ^. input) (w ^. wCam))
|
BezierTrajectoryType -> BezierTrajectory bulpos tp (mouseWorldPos (w ^. input) (w ^. wCam))
|
||||||
MagnetTrajectoryType -> MagnetTrajectory tp
|
MagnetTrajectoryType -> MagnetTrajectory tp
|
||||||
where
|
where
|
||||||
bulpos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm + V2 0 offset)
|
(moff,mrot) = heldItemOrient2D itm cr (_mzPos mz + V2 0 offset) (_mzRot mz)
|
||||||
|
bulpos = _crPos cr + rotateV (_crDir cr) moff
|
||||||
|
-- dir = _crDir cr + mrot + a
|
||||||
|
-- bulpos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm + V2 0 offset)
|
||||||
offset = case itm ^? itUse . heldParams . randomOffset of
|
offset = case itm ^? itUse . heldParams . randomOffset of
|
||||||
Just x | x /= 0 -> fst . randomR (- x, x) $ _randGen w
|
Just x | x /= 0 -> fst . randomR (- x, x) $ _randGen w
|
||||||
_ -> 0
|
_ -> 0
|
||||||
@@ -392,8 +397,6 @@ makeBullet thebullet itm cr mz w =
|
|||||||
& buDrag *~ drag
|
& buDrag *~ drag
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
-- bulpos = _crPos cr
|
|
||||||
-- + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm + V2 0 offset)
|
|
||||||
(moff,mrot) = heldItemOrient2D itm cr (_mzPos mz + V2 0 offset) (_mzRot mz)
|
(moff,mrot) = heldItemOrient2D itm cr (_mzPos mz + V2 0 offset) (_mzRot mz)
|
||||||
bulpos = _crPos cr + rotateV (_crDir cr) moff
|
bulpos = _crPos cr + rotateV (_crDir cr) moff
|
||||||
(a, g'') = randomR (- inacc, inacc) $ _randGen w
|
(a, g'') = randomR (- inacc, inacc) $ _randGen w
|
||||||
@@ -438,10 +441,12 @@ useGasParams mmagid mz itm cr w =
|
|||||||
fueltype <- cr ^? crInv . ix magid . itUse . amagParams . ampCreateGas
|
fueltype <- cr ^? crInv . ix magid . itUse . amagParams . ampCreateGas
|
||||||
gc <- itm ^? itUse . heldParams . gasCreation
|
gc <- itm ^? itUse . heldParams . gasCreation
|
||||||
return $ gasCreate fueltype gc
|
return $ gasCreate fueltype gc
|
||||||
pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
|
--pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
|
||||||
|
(moff,mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
|
||||||
|
pos = _crPos cr + rotateV (_crDir cr) moff
|
||||||
(a, g') = randomR (- inacc, inacc) g
|
(a, g') = randomR (- inacc, inacc) g
|
||||||
inacc = _mzInaccuracy mz
|
inacc = _mzInaccuracy mz
|
||||||
dir = _crDir cr + _mzRot mz + a + _nzCurrentWalkAngle (_mzEffect mz)
|
dir = _crDir cr + mrot + a + _nzCurrentWalkAngle (_mzEffect mz)
|
||||||
|
|
||||||
gasCreate :: GasFuel -> GasCreate -> GasCreate
|
gasCreate :: GasFuel -> GasCreate -> GasCreate
|
||||||
gasCreate = const id
|
gasCreate = const id
|
||||||
@@ -487,8 +492,9 @@ shootTeslaArc itm cr mz w =
|
|||||||
-- use items item location instead
|
-- use items item location instead
|
||||||
itRef = cr ^?! crManipulation . manObject . imRootSelectedItem -- unsafe!! TODO change
|
itRef = cr ^?! crManipulation . manObject . imRootSelectedItem -- unsafe!! TODO change
|
||||||
(w', ip) = makeTeslaArc (_itParams itm) pos dir w
|
(w', ip) = makeTeslaArc (_itParams itm) pos dir w
|
||||||
pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
|
(moff,mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
|
||||||
dir = _crDir cr + _mzRot mz
|
pos = _crPos cr + rotateV (_crDir cr) moff
|
||||||
|
dir = _crDir cr + mrot
|
||||||
|
|
||||||
determineProjectileTracking ::
|
determineProjectileTracking ::
|
||||||
LabelDoubleTree ComposeLinkType Item ->
|
LabelDoubleTree ComposeLinkType Item ->
|
||||||
|
|||||||
@@ -61,6 +61,21 @@ heldItemRelativeOrient itm cr (p,q)
|
|||||||
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
|
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
|
||||||
sLen = _strideLength $ _crStance cr
|
sLen = _strideLength $ _crStance cr
|
||||||
|
|
||||||
|
aimingWeaponZeroPos :: Creature -> Item -> Point2
|
||||||
|
aimingWeaponZeroPos cr it =
|
||||||
|
aimingWeaponHandlePos cr it
|
||||||
|
- fromMaybe 0 (it ^? itUse . heldAim . aimHandlePos)
|
||||||
|
|
||||||
|
-- the position of a weapon handle
|
||||||
|
aimingWeaponHandlePos :: Creature -> Item -> Point2
|
||||||
|
aimingWeaponHandlePos _ it = case it ^? itUse . heldAim . aimStance of
|
||||||
|
Just TwoHandUnder -> V2 (-2) 0
|
||||||
|
Just TwoHandOver -> V2 (-7) 0
|
||||||
|
Just OneHand -> V2 10 (-2)
|
||||||
|
Just TwoHandFlat -> V2 10 0
|
||||||
|
Nothing -> 0
|
||||||
|
|
||||||
|
|
||||||
heldItemOffset :: Item -> Creature -> Point3 -> Point3
|
heldItemOffset :: Item -> Creature -> Point3 -> Point3
|
||||||
heldItemOffset itm cr p = fst (heldItemRelativeOrient itm cr (p,Q.qID))
|
heldItemOffset itm cr p = fst (heldItemRelativeOrient itm cr (p,Q.qID))
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ module Dodge.Item.Weapon.Shatter where
|
|||||||
|
|
||||||
import Dodge.Base.Collide
|
import Dodge.Base.Collide
|
||||||
import Dodge.Block.Debris
|
import Dodge.Block.Debris
|
||||||
import Dodge.Creature.HandPos
|
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
import Dodge.Wall.Damage
|
import Dodge.Wall.Damage
|
||||||
import Geometry
|
import Geometry
|
||||||
@@ -10,7 +9,7 @@ import LensHelp
|
|||||||
|
|
||||||
|
|
||||||
shootShatter :: Item -> Creature -> World -> World
|
shootShatter :: Item -> Creature -> World -> World
|
||||||
shootShatter it cr w =
|
shootShatter _ cr w =
|
||||||
maybe w (uncurry $ shatterWall w sp ep) $
|
maybe w (uncurry $ shatterWall w sp ep) $
|
||||||
sequence $
|
sequence $
|
||||||
collidePointWallsFilter canshatter sp ep w
|
collidePointWallsFilter canshatter sp ep w
|
||||||
@@ -19,7 +18,8 @@ shootShatter it cr w =
|
|||||||
Opaque {} -> True
|
Opaque {} -> True
|
||||||
SeeThrough -> True
|
SeeThrough -> True
|
||||||
_ -> False
|
_ -> False
|
||||||
sp = _crPos cr +.+ aimingMuzzleLength cr it *.* unitVectorAtAngle dir
|
sp = _crPos cr +.+ 10 *.* unitVectorAtAngle dir
|
||||||
|
-- the 10 is arbtrary and should be changed to a muzzle position
|
||||||
dir = _crDir cr
|
dir = _crDir cr
|
||||||
ep = sp +.+ 200 *.* unitVectorAtAngle dir
|
ep = sp +.+ 200 *.* unitVectorAtAngle dir
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user