diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index eb0e9c16b..a625e42a3 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -10,6 +10,7 @@ circular imports are probably not a good idea. {-# LANGUAGE DerivingStrategies #-} module Dodge.Data ( module Dodge.Data + , module Dodge.Data.Ammo , module Dodge.Data.Payload , module Dodge.Data.RadarSweep , module Dodge.Data.PosEvent @@ -54,6 +55,7 @@ module Dodge.Data , module Dodge.Data.RadarBlip , module Dodge.Data.PathGraph ) where +import Dodge.Data.Ammo import Dodge.Data.Payload import Dodge.Data.RadarSweep import Dodge.Data.PosEvent @@ -590,9 +592,9 @@ type HitEffect' = Flame data AmmoType = ProjectileAmmo - { _amPayload :: Point2 -> World -> World + { _amPayload :: Payload , _amString :: String - , _amPjDraw :: Prop -> SPic + , _amPjDraw :: ProjectileDraw , _amPjCreation :: Item -> Creature -> World -> World } | BulletAmmo diff --git a/src/Dodge/Data/Ammo.hs b/src/Dodge/Data/Ammo.hs index b54b66ceb..f66674749 100644 --- a/src/Dodge/Data/Ammo.hs +++ b/src/Dodge/Data/Ammo.hs @@ -2,3 +2,6 @@ --{-# LANGUAGE StrictData #-} module Dodge.Data.Ammo where +data ProjectileDraw = DrawShell | DrawRemoteShell +data ProjectileCreate = CreateShell + diff --git a/src/Dodge/Item/Weapon/Drone.hs b/src/Dodge/Item/Weapon/Drone.hs index 895edf7d8..8ca30467a 100644 --- a/src/Dodge/Item/Weapon/Drone.hs +++ b/src/Dodge/Item/Weapon/Drone.hs @@ -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 } diff --git a/src/Dodge/Item/Weapon/Launcher.hs b/src/Dodge/Item/Weapon/Launcher.hs index 4caed908c..4c04ae296 100644 --- a/src/Dodge/Item/Weapon/Launcher.hs +++ b/src/Dodge/Item/Weapon/Launcher.hs @@ -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 diff --git a/src/Dodge/Projectile.hs b/src/Dodge/Projectile.hs index cfeb0284e..095f1f567 100644 --- a/src/Dodge/Projectile.hs +++ b/src/Dodge/Projectile.hs @@ -1,8 +1,9 @@ module Dodge.Projectile where +import Dodge.Data ---createProjectile :: ProjectileType -> Item -> Creature -> World -> World ---createProjectile pt = case pt of --- ShellType -> fireShell +createProjectile :: ProjectileCreate -> Item -> Creature -> World -> World +createProjectile pt = case pt of + CreateShell -> undefined -- --fireShell :: Item -> Creature -> World -> World --fireShell it cr = makeShell it cr $ \pj -> pjEffAtTime 35 (trySpinByCID (_crID cr) spinamount) pj diff --git a/src/Dodge/Projectile/Draw.hs b/src/Dodge/Projectile/Draw.hs new file mode 100644 index 000000000..06d6f4a38 --- /dev/null +++ b/src/Dodge/Projectile/Draw.hs @@ -0,0 +1,34 @@ +module Dodge.Projectile.Draw where +import Dodge.Data +import Geometry +import Picture +import Shape +import ShapePicture + +drawProjectile :: ProjectileDraw -> Prop -> SPic +drawProjectile pd = case pd of + DrawShell -> drawShell + DrawRemoteShell -> drawRemoteShell + +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)] +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) +remoteShellShape :: Color -> SPic +remoteShellShape col = (shellShape + , setLayer BloomNoZWrite . setDepth 4.5 . color col $ circleSolid 3 + ) +