Move toward external function for shell update
This commit is contained in:
@@ -4,5 +4,11 @@ module Dodge.Data.Ammo where
|
||||
|
||||
data ProjectileDraw = DrawShell | DrawRemoteShell | DrawDrone | DrawBlankProjectile
|
||||
data ProjectileCreate = CreateShell
|
||||
data ProjectileUpdate = LaunchPJ | SpinPJ | ThrustPJ | FloatPJ
|
||||
data ProjectileUpdate
|
||||
= PJThrust {_pjuStart :: Int, _pjuEnd :: Int}
|
||||
| PJSpin {_pjuTime :: Int, _pjuCID :: Int, _pjuSpinAmound :: Int}
|
||||
| PJTrack {_pjuStart :: Int, _pjuEnd :: Int, _pjuITID :: Int}
|
||||
| PJReduceSpin {_pjuReduceSpin :: Float}
|
||||
| PJRemoteDirection {_pjuStart :: Int, _pjuEnd :: Int}
|
||||
| PJPayload {_pjuTime :: Int}
|
||||
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
module Dodge.Projectile.Create where
|
||||
import Dodge.Data
|
||||
import Dodge.Item.Weapon.Shell
|
||||
import Dodge.Base.Collide
|
||||
import Dodge.Base
|
||||
import Dodge.Payload
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.Movement.Turn
|
||||
import Dodge.Item.Location
|
||||
import Dodge.EnergyBall
|
||||
import Dodge.WorldEvent.Cloud
|
||||
import LensHelp
|
||||
import qualified IntMapHelp as IM
|
||||
import Geometry
|
||||
import RandomHelp
|
||||
|
||||
import Data.Maybe
|
||||
|
||||
createProjectile :: ProjectileCreate -> Item -> Creature -> World -> World
|
||||
createProjectile pt = case pt of
|
||||
CreateShell -> undefined
|
||||
--CreateRemoteShell -> undefined
|
||||
|
||||
--fireShell :: Item -> Creature -> World -> World
|
||||
--fireShell it cr = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj
|
||||
-- . pjThrust thrustdelay pj
|
||||
-- . reduceSpinBy (1-fromIntegral spindrag*2 / 200) pj
|
||||
-- . decTimMvVel pj
|
||||
-- . moveShell pj
|
||||
-- where
|
||||
-- params = _itParams it
|
||||
-- spindrag = _shellSpinDrag params
|
||||
-- spinamount = _shellSpinAmount params
|
||||
-- thrustdelay = _shellThrustDelay params
|
||||
--
|
||||
--makeShell :: Item -> Creature -> (Proj -> World -> World) -> World -> World
|
||||
--makeShell it cr theupdate w = w & projectiles %~ IM.insert i Shell
|
||||
-- { _prjPos = pos
|
||||
-- , _prjZ = 20
|
||||
-- , _prjStartPos = pos
|
||||
-- , _prjVel = rotateV dir (V2 1 0)
|
||||
-- , _prjID = i
|
||||
-- , _prjUpdate = theupdate
|
||||
-- , _prjAcc = rotateV dir (V2 3 0)
|
||||
-- , _prjDir = dir
|
||||
-- , _prjDraw = DrawShell
|
||||
-- , _prjSpin = 0
|
||||
-- , _prjPayload = _amPayload $ _laAmmoType am
|
||||
-- , _prjTimer = 50
|
||||
-- }
|
||||
-- where
|
||||
-- i = IM.newKey $ _props w
|
||||
-- dir = _crDir cr
|
||||
-- pos = _crPos cr +.+ rotateV dir (V2 (_crRad cr + 1) 0)
|
||||
-- am = _itConsumption it
|
||||
--
|
||||
--moveShell :: Proj
|
||||
-- -> World
|
||||
-- -> World
|
||||
--moveShell pj w
|
||||
-- | time > 40 = if circOnSomeWall oldPos 4 w
|
||||
-- then doExplode
|
||||
-- else w
|
||||
-- | anythingHitCirc 2 oldPos newPos w = doExplode
|
||||
-- | time > -300 = w
|
||||
-- | otherwise = doExplode
|
||||
-- where
|
||||
-- time = _prjTimer pj
|
||||
-- doExplode = w
|
||||
-- & usePayload (_prjPayload pj) oldPos
|
||||
-- & stopSoundFrom (ShellSound i)
|
||||
-- & props %~ IM.delete i
|
||||
-- i = _prjID pj
|
||||
-- oldPos = _prjPos pj
|
||||
-- vel = _prjVel pj
|
||||
-- newPos = oldPos +.+ vel
|
||||
--
|
||||
--usePjCreation :: Item -> Creature -> World -> World
|
||||
--usePjCreation it = createProjectile (_amPjCreation (_laAmmoType (_itConsumption it))) it
|
||||
--
|
||||
--usePjCreationX :: Int -> Item -> Creature -> World -> World
|
||||
--usePjCreationX i it cr = foldr f
|
||||
-- (createProjectile (_amPjCreation (_laAmmoType (_itConsumption it))) it cr)
|
||||
-- [1..i-1]
|
||||
-- where
|
||||
-- f n = (. createProjectile (_amPjCreation (_laAmmoType (_itConsumption it))) it (cr & crDir +~ (2*pi*fromIntegral n / fromIntegral i)))
|
||||
--
|
||||
--pjEffAtTime
|
||||
-- :: Int
|
||||
-- -> (Proj -> World -> World)
|
||||
-- -> Proj
|
||||
-- -> World
|
||||
-- -> World
|
||||
--pjEffAtTime t f pj
|
||||
-- | _prjTimer pj == t = f pj
|
||||
-- | otherwise = id
|
||||
--
|
||||
--trySpinByCID
|
||||
-- :: Int -- ^ creature id
|
||||
-- -> Int -- ^ Spin amount
|
||||
-- -> Proj
|
||||
-- -> World
|
||||
-- -> World
|
||||
--trySpinByCID cid i pj w = w & projectiles . ix pjid . prjSpin .~ newSpin
|
||||
-- where
|
||||
-- pjid = _prjID pj
|
||||
-- dir = argV $ _prjVel pj
|
||||
-- newSpin = case w ^? creatures . ix cid of
|
||||
-- Just cr -> negate $ min 0.2 $ max (-0.2) $ normalizeAnglePi (dir - _crDir cr) / spinFactor
|
||||
-- _ -> 0
|
||||
-- spinFactor = 5 * (6 - fromIntegral i)
|
||||
--pjThrust :: Int -> Proj -> World -> World
|
||||
--pjThrust i = pjEffTimeRange (st,et) doThrust
|
||||
-- where
|
||||
-- et | i == 0 = 36
|
||||
-- | otherwise = 40 - (i * 20)
|
||||
-- st = et - 100
|
||||
--
|
||||
--pjTrack :: Int -> Int -> Proj -> World -> World
|
||||
--pjTrack itid i pj w = pjEffTimeRange (st,et) rotateToTarget pj w
|
||||
-- where
|
||||
-- et | i == 0 = 36
|
||||
-- | otherwise = 40 - (i * 20)
|
||||
-- st = et - 100
|
||||
-- rotateToTarget _ = fromMaybe id $ do
|
||||
-- tpos <- w ^? itPoint . itTargeting . tgPos . _Just
|
||||
-- return $ projectiles . ix (_prjID pj) . prjSpin .~ turnToAmount 0.15 (_prjPos pj) tpos
|
||||
-- (argV $ _prjAcc pj)
|
||||
-- itPoint = pointToItem $ _itemPositions w IM.! itid
|
||||
--
|
||||
--doThrust :: Proj -> World -> World
|
||||
--doThrust pj w = w
|
||||
-- & randGen .~ g
|
||||
-- & projectiles . ix i . prjVel %~ (\v -> accel +.+ frict *.* v)
|
||||
-- & soundContinue (ShellSound i) newPos missileLaunchS (Just 1)
|
||||
-- & makeFlamelet (oldPos -.- vel) 0 (vel +.+ rotateV (pi+sparkD) accel) 3 10
|
||||
-- & shellTrailCloud (addZ 20 (oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos)))
|
||||
-- where
|
||||
-- accel = _prjAcc pj
|
||||
-- i = _prjID pj
|
||||
-- oldPos = _prjPos pj
|
||||
-- vel = _prjVel pj
|
||||
-- newPos = oldPos +.+ vel
|
||||
-- (frict,g) = randomR (0.6,0.9) $ _randGen w
|
||||
-- (sparkD,_) = randomR (-0.2,0.2) $ _randGen w
|
||||
-- r1 = randInCirc 10 & evalState $ _randGen w
|
||||
--
|
||||
--reduceSpinBy :: Float -> Proj -> World -> World
|
||||
--reduceSpinBy x pj = projectiles . ix (_prjID pj) . prjSpin *~ x
|
||||
--
|
||||
--pjEffTimeRange
|
||||
-- :: (Int,Int)
|
||||
-- -> (Proj -> World -> World)
|
||||
-- -> Proj
|
||||
-- -> World
|
||||
-- -> World
|
||||
--pjEffTimeRange (st,et) f pj
|
||||
-- | t <= et && t >= st = f pj
|
||||
-- | otherwise = id
|
||||
-- where
|
||||
-- t = _prjTimer pj
|
||||
@@ -0,0 +1,2 @@
|
||||
module Dodge.Projectile.Update where
|
||||
--import Dodge.Data
|
||||
Reference in New Issue
Block a user