Start projectile refactor

This commit is contained in:
2022-07-20 01:44:16 +01:00
parent 6e901d3086
commit 9daf872878
6 changed files with 56 additions and 38 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
module Dodge.Item.Weapon.Drone where
import Dodge.Projectile.Draw
import Dodge.Data
import Dodge.Default.Weapon
--import Dodge.Default
@@ -59,7 +60,7 @@ aDroneWithItemParams it cr w = over props (IM.insert i theShell) w
{ _prPos = pos
, _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0)
, _prDraw = _amPjDraw $ _laAmmoType am
, _prDraw = drawProjectile (_amPjDraw $ _laAmmoType am)
, _pjID = i
, _pjUpdate = const id
}
+9 -32
View File
@@ -5,12 +5,13 @@ module Dodge.Item.Weapon.Launcher
, fireTrackingShell
) where
import Dodge.Data
import Dodge.Payload
import Dodge.Projectile.Draw
import Dodge.Reloading.Action
import Dodge.EnergyBall
import Dodge.Default.Weapon
import Dodge.Item.Location
import Dodge.SoundLogic.LoadSound
import Dodge.WorldEvent.Explosion
import Dodge.Item.Weapon.Shell
import Dodge.Item.Weapon.Remote
import Dodge.Item.Weapon.TriggerType
@@ -21,11 +22,7 @@ import Dodge.SoundLogic
import Dodge.WorldEvent.Cloud
import RandomHelp
import Geometry
import Picture
import qualified IntMapHelp as IM
--import Padding
import ShapePicture
import Shape
import qualified Streaming.Prelude as S
--import qualified Data.Set as S
@@ -38,9 +35,9 @@ launcher :: Item
launcher = defaultWeapon
{ _itConsumption = defaultLoadable
& laAmmoType .~ ProjectileAmmo
{ _amPayload = makeExplosionAt
{ _amPayload = ExplosionPayload
, _amString = "EXPLOSIVE SHELL"
, _amPjDraw = drawShell
, _amPjDraw = DrawShell
, _amPjCreation = fireShell
}
& laMax .~ 1
@@ -202,30 +199,10 @@ moveShell pj w
reduceSpinBy :: Float -> Prop -> World -> World
reduceSpinBy x pj = props . ix (_pjID pj) . pjSpin *~ x
drawShell :: Prop -> SPic
drawShell pj = noPic
. translateSHz 18
. uncurryV translateSHf (_prPos pj)
$ rotateSH (argV $ _pjAcc pj) shellShape
shellShape :: Shape
shellShape = colorSH black $ upperPrismPoly 4 $ map toV2 [(-6,4),(-6,-4),(6,-4),(8,0),(6,4)]
--shellShape :: Shape
--shellShape = colorSH black $ upperPrismPoly 4 $ map toV2 [(-6,4),(-6,-4),(6,-4),(8,0),(6,4)]
remoteShellShape :: Color -> SPic
remoteShellShape col = (shellShape
, setLayer BloomNoZWrite . setDepth 4.5 . color col $ circleSolid 3
)
drawRemoteShell :: Prop -> SPic
drawRemoteShell pj
| rem (t+200) 20 < 9
= doposition $ noPic shellShape
| otherwise = doposition $ remoteShellShape col
where
col | t > (-99) = green
| otherwise = red
t = _pjTimer pj
doposition = translateSPz 18 . uncurryV translateSPf (_prPos pj) . rotateSP (_pjDir pj)
pjEffTimeRange
:: (Int,Int)
@@ -269,7 +246,7 @@ remoteLauncher = launcher
& itType . iyBase .~ HELD REMOTELAUNCHER
& itUse . rUse .~ fireRemoteShell
& itScope .~ RemoteScope (V2 0 0) 1 True
& itConsumption . laAmmoType . amPjDraw .~ drawRemoteShell
& itConsumption . laAmmoType . amPjDraw .~ DrawRemoteShell
-- TODO consider allowing tweaking rocket speed
fireRemoteShell :: Item -> Creature -> World -> World
@@ -363,13 +340,13 @@ makeShell it cr theupdate w = w & props %~ IM.insert i Shell
, _pjZ = 20
, _pjStartPos = pos
, _pjVel = rotateV dir (V2 1 0)
, _prDraw = _amPjDraw $ _laAmmoType am
, _prDraw = drawProjectile (_amPjDraw $ _laAmmoType am)
, _pjID = i
, _pjUpdate = theupdate
, _pjAcc = rotateV dir (V2 3 0)
, _pjDir = dir
, _pjSpin = 0
, _pjPayload = _amPayload $ _laAmmoType am
, _pjPayload = usePayload $ _amPayload $ _laAmmoType am
, _pjTimer = 50
}
where