Refactor projectiles, fix shell drawing
This commit is contained in:
@@ -13,7 +13,7 @@ import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
|
||||
-- assumes the mscreen is in your inventory
|
||||
createShell :: ProjectileHoming
|
||||
createShell :: RocketHoming
|
||||
-> Maybe (NewInt ItmInt)
|
||||
-> Maybe (NewInt ItmInt)
|
||||
-> Bool
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
module Dodge.Projectile.Draw
|
||||
( drawProjectile
|
||||
) where
|
||||
module Dodge.Projectile.Draw (
|
||||
drawProjectile,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Data.Strict.Tuple
|
||||
import Dodge.Data.Item.Use.Consumption.Ammo
|
||||
import Dodge.Data.Projectile
|
||||
@@ -9,40 +10,37 @@ import Geometry
|
||||
import Picture
|
||||
import Shape
|
||||
import ShapePicture
|
||||
import Control.Lens
|
||||
|
||||
drawProjectile :: Projectile -> SPic
|
||||
drawProjectile pj
|
||||
| Just (DestroyPU {}) <- pj ^? prjUpdates . ix 0 = mempty
|
||||
| Just NoHoming <- pj ^? prjType . rocketHoming =
|
||||
drawProjectile pj
|
||||
| Just (DestroyPU{}) <- pj ^? prjUpdates . ix 0 = mempty
|
||||
| Just NoHoming <- pj ^? prjType . rkHoming =
|
||||
drawShell Nothing pj
|
||||
| Just _ <- pj ^? prjType . rocketHoming =
|
||||
| Just _ <- pj ^? prjType . rkHoming =
|
||||
drawRemoteShell pj
|
||||
| otherwise = drawShell Nothing pj
|
||||
|
||||
drawShell :: Maybe Color -> Projectile -> SPic
|
||||
drawShell mcol pj =
|
||||
noPic
|
||||
. translateSHz (_prjZ pj)
|
||||
. uncurryV translateSHxy (_prjPos pj)
|
||||
$ rotateSH (_prjDir pj) shellShape
|
||||
translateSPz (_prjZ pj)
|
||||
. uncurryV translateSPxy (_prjPos pj)
|
||||
$ rotateSP (_prjDir pj) $
|
||||
shellShape :!: thelight
|
||||
where
|
||||
thelight =
|
||||
foldMap
|
||||
(\col -> setLayer BloomNoZWrite . setDepth 4.5 . color col $ circleSolid 3)
|
||||
mcol
|
||||
|
||||
shellShape :: Shape
|
||||
shellShape = colorSH black $ upperPrismPoly Small Typical 4 $ map toV2 [(-6, 4), (-6, -4), (6, -4), (8, 0), (6, 4)]
|
||||
|
||||
drawRemoteShell :: Projectile -> SPic
|
||||
drawRemoteShell pj
|
||||
| rem (t + 200) 20 < 9 =
|
||||
doposition $ noPic shellShape
|
||||
| otherwise = doposition $ remoteShellShape col
|
||||
| rem (t + 200) 20 < 9 = drawShell Nothing pj
|
||||
| otherwise = drawShell (Just col) pj
|
||||
where
|
||||
col
|
||||
| t > (-99) = green
|
||||
| otherwise = red
|
||||
t = _prjTimer pj
|
||||
doposition = translateSPz 18 . uncurryV translateSPxy (_prjPos pj) . rotateSP (_prjDir pj)
|
||||
|
||||
remoteShellShape :: Color -> SPic
|
||||
remoteShellShape col =
|
||||
shellShape
|
||||
:!: ( setLayer BloomNoZWrite . setDepth 4.5 . color col $ circleSolid 3)
|
||||
|
||||
@@ -40,7 +40,7 @@ upProjectile pu pj = case pu of
|
||||
| time == t -> trySpinByCID cid spinamount pj
|
||||
| otherwise -> id
|
||||
RemoteDirectionPU st et
|
||||
| act st et -> pjRemoteSetDirection (pj ^? prjType . rocketHoming) pj
|
||||
| act st et -> pjRemoteSetDirection (pj ^? prjType . rkHoming) pj
|
||||
| otherwise -> id
|
||||
ReduceSpinPU x -> reduceSpinBy x (_prjID pj)
|
||||
DestroyPU mitid 0 -> destroyProjectile mitid (_prjID pj)
|
||||
@@ -156,7 +156,7 @@ trySpinByCID cid i pj w = w & cWorld . lWorld . projectiles . ix pjid . prjSpin
|
||||
spinFactor = 5 * (6 - fromIntegral i)
|
||||
|
||||
-- note this only allows YOU to remotely track projectiles
|
||||
pjRemoteSetDirection :: Maybe ProjectileHoming -> Projectile -> World -> World
|
||||
pjRemoteSetDirection :: Maybe RocketHoming -> Projectile -> World -> World
|
||||
pjRemoteSetDirection ph pj w = case ph of
|
||||
Just (HomeUsingRemoteScreen screenid)
|
||||
| lw ^? creatures . ix 0 . crManipulation . manObject . imSelectedItem
|
||||
|
||||
Reference in New Issue
Block a user