Move bullet trajectory into bullet update function
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
module Dodge.Item.Draw.SPic where
|
||||
import Dodge.Data
|
||||
import Dodge.Item.Weapon.AmmoParams
|
||||
import Dodge.Item.Weapon.FractionLoaded
|
||||
import ShapePicture
|
||||
import Shape
|
||||
import LensHelp
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
module Dodge.Item.Weapon.AmmoParams
|
||||
( useAmmoParams
|
||||
, fractionLoadedAmmo
|
||||
, fractionLoadedAmmo2
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Base
|
||||
import Dodge.Particle.Bullet.Spawn
|
||||
import Dodge.Creature.HandPos
|
||||
import Dodge.Movement.Turn
|
||||
import Geometry
|
||||
import LensHelp
|
||||
|
||||
import Data.Maybe
|
||||
--import Control.Lens
|
||||
|
||||
useAmmoParams :: Maybe Float -> Item -> Creature -> World -> World
|
||||
useAmmoParams vfact it cr w = w & instantBullets .:~ aBulAt
|
||||
vfact
|
||||
thetraj -- extra update
|
||||
sp
|
||||
(rotateV dir (muzvel *.* _amBulVel bultype)) -- vel
|
||||
(_rifling $ _itParams it) -- drag
|
||||
(_amBulEff bultype)
|
||||
(_amBulWth bultype)
|
||||
where
|
||||
sp = _crPos cr +.+ (muzlength + 10) *.* unitVectorAtAngle dir
|
||||
dir = _crDir cr
|
||||
bultype = _laAmmoType $ _itConsumption it
|
||||
muzvel = _muzVel $ _itParams it
|
||||
muzlength = aimingMuzzlePos cr it
|
||||
thetraj = case _amBulTraj bultype of
|
||||
BasicBulletTrajectory -> id
|
||||
MagnetTrajectory -> fromMaybe id $ do
|
||||
tpos <- it ^? itTargeting . tgPos . _Just
|
||||
return $ \pt -> pt & buVel .+.+~ 5 *.* normalizeV (tpos -.- _buPos pt)
|
||||
FlechetteTrajectory -> fromMaybe id $ do
|
||||
tpos <- it ^? itTargeting . tgPos . _Just
|
||||
return $ \pt -> pt & buVel %~ vecTurnTo 0.2 (_buPos pt) tpos
|
||||
BezierTrajectory -> fromMaybe id $ do
|
||||
tpos <- it ^? itTargeting . tgPos . _Just
|
||||
let bf t = bQuadToF (sp,mouseWorldPos w,tpos) $ (100 - t) * 0.05
|
||||
return $ \pt -> pt
|
||||
& buVel .~ bf (fromIntegral $ _buTimer pt - 1) -.- bf (fromIntegral $ _buTimer pt)
|
||||
|
||||
---- this shouldn't really be used
|
||||
loadedAmmo :: Item -> Int
|
||||
loadedAmmo = _laLoaded . _itConsumption
|
||||
-- | _laTransfer (_itConsumption it) == NoTransfer = _laLoaded (_itConsumption it)
|
||||
-- | otherwise = 0
|
||||
|
||||
fractionLoadedAmmo :: Item -> Float
|
||||
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (itmaxammo it)
|
||||
where
|
||||
itmaxammo = _laMax . _itConsumption
|
||||
|
||||
fractionLoadedAmmo2 :: Item -> Float
|
||||
fractionLoadedAmmo2 it = 1 -
|
||||
(1 - fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it))**2
|
||||
where
|
||||
itMaxAmmo = _laMax . _itConsumption
|
||||
@@ -11,14 +11,9 @@ module Dodge.Item.Weapon.BulletGun.Cane
|
||||
--import Dodge.Particle.Bullet.HitEffect
|
||||
import Dodge.Reloading.Action
|
||||
import Dodge.Data
|
||||
--import Dodge.ChainEffect
|
||||
import Dodge.Bullet
|
||||
import Dodge.Default.Weapon
|
||||
import Dodge.Default
|
||||
--import Dodge.Item.Attachment
|
||||
--import Dodge.Item.Weapon.ExtraEffect
|
||||
--import Dodge.Item.Weapon.InventoryDisplay
|
||||
import Dodge.Item.Weapon.AmmoParams
|
||||
--import Dodge.Item.Draw
|
||||
import Dodge.Item.Weapon.TriggerType
|
||||
import Dodge.SoundLogic.LoadSound
|
||||
import Picture
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
module Dodge.Item.Weapon.FractionLoaded
|
||||
( fractionLoadedAmmo
|
||||
, fractionLoadedAmmo2
|
||||
) where
|
||||
import Dodge.Data
|
||||
|
||||
---- this shouldn't really be used
|
||||
loadedAmmo :: Item -> Int
|
||||
loadedAmmo = _laLoaded . _itConsumption
|
||||
-- | _laTransfer (_itConsumption it) == NoTransfer = _laLoaded (_itConsumption it)
|
||||
-- | otherwise = 0
|
||||
|
||||
fractionLoadedAmmo :: Item -> Float
|
||||
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (itmaxammo it)
|
||||
where
|
||||
itmaxammo = _laMax . _itConsumption
|
||||
|
||||
fractionLoadedAmmo2 :: Item -> Float
|
||||
fractionLoadedAmmo2 it = 1 -
|
||||
(1 - fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it))**2
|
||||
where
|
||||
itMaxAmmo = _laMax . _itConsumption
|
||||
Reference in New Issue
Block a user