Refactor shells
This commit is contained in:
@@ -12,12 +12,6 @@ import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
|
||||
homingDrawType :: ProjectileHoming -> ProjectileDraw
|
||||
homingDrawType ht = case ht of
|
||||
NoHoming -> DrawShell
|
||||
HomeUsingRemoteScreen {} -> DrawRemoteShell
|
||||
HomeUsingTargeting {} -> DrawRemoteShell
|
||||
|
||||
-- assumes the mscreen is in your inventory
|
||||
createShell :: ProjectileHoming
|
||||
-> Maybe (NewInt ItmInt)
|
||||
@@ -34,7 +28,6 @@ createShell homing mdetonator mscreen smokestatus pjtype payload muz cr w = w
|
||||
, _prjZ = 20
|
||||
, _prjZVel = 5
|
||||
, _prjVel = rotateV dir (V2 speed 0) + cr ^. crPos - cr ^. crOldPos
|
||||
, _prjDraw = homingDrawType homing
|
||||
, _prjID = i
|
||||
-- , _prjAcc = rotateV dir (V2 3 0)
|
||||
, _prjDir = dir
|
||||
@@ -45,7 +38,7 @@ createShell homing mdetonator mscreen smokestatus pjtype payload muz cr w = w
|
||||
[ CollisionEffectPU (homing ^? phRemoteID) mdetonator mscreen
|
||||
, TimePU
|
||||
, StartSpinPU (lifespan - 15) (_crID cr) spinamount
|
||||
, RemoteDirectionPU (lifespan - thrustdelay) 0 homing
|
||||
, RemoteDirectionPU (lifespan - thrustdelay) 0
|
||||
, ReduceSpinPU (1 - spindrag * 2 / 200)
|
||||
] <> thrustorgrav
|
||||
, _prjType = pjtype
|
||||
@@ -53,13 +46,13 @@ createShell homing mdetonator mscreen smokestatus pjtype payload muz cr w = w
|
||||
where
|
||||
speed = case pjtype of
|
||||
Grenade -> 4
|
||||
Rocket -> 1
|
||||
Rocket{} -> 1
|
||||
lifespan = case pjtype of
|
||||
Grenade -> 150
|
||||
Rocket -> 350
|
||||
Rocket{} -> 350
|
||||
thrustorgrav = case pjtype of
|
||||
Grenade -> [ApplyGravityPU]
|
||||
Rocket -> [ThrustPU (lifespan - thrustdelay) 0 smokestatus]
|
||||
Rocket{} -> [ThrustPU (lifespan - thrustdelay) 0 smokestatus]
|
||||
spindrag = 1
|
||||
spinamount = 2
|
||||
thrustdelay = 20
|
||||
|
||||
@@ -9,16 +9,19 @@ import Geometry
|
||||
import Picture
|
||||
import Shape
|
||||
import ShapePicture
|
||||
import Control.Lens
|
||||
|
||||
drawProjectile :: Projectile -> SPic
|
||||
drawProjectile prj = case _prjDraw prj of
|
||||
DrawShell -> drawShell prj
|
||||
DrawRemoteShell -> drawRemoteShell prj
|
||||
DrawDrone -> drawShell prj
|
||||
DrawBlankProjectile -> mempty
|
||||
drawProjectile pj
|
||||
| Just (DestroyPU {}) <- pj ^? prjUpdates . ix 0 = mempty
|
||||
| Just NoHoming <- pj ^? prjType . rocketHoming =
|
||||
drawShell Nothing pj
|
||||
| Just _ <- pj ^? prjType . rocketHoming =
|
||||
drawRemoteShell pj
|
||||
| otherwise = drawShell Nothing pj
|
||||
|
||||
drawShell :: Projectile -> SPic
|
||||
drawShell pj =
|
||||
drawShell :: Maybe Color -> Projectile -> SPic
|
||||
drawShell mcol pj =
|
||||
noPic
|
||||
. translateSHz (_prjZ pj)
|
||||
. uncurryV translateSHxy (_prjPos pj)
|
||||
|
||||
@@ -39,8 +39,8 @@ upProjectile pu pj = case pu of
|
||||
StartSpinPU t cid spinamount
|
||||
| time == t -> trySpinByCID cid spinamount pj
|
||||
| otherwise -> id
|
||||
RemoteDirectionPU st et mscreenid
|
||||
| act st et -> pjRemoteSetDirection mscreenid pj
|
||||
RemoteDirectionPU st et
|
||||
| act st et -> pjRemoteSetDirection (pj ^? prjType . rocketHoming) pj
|
||||
| otherwise -> id
|
||||
ReduceSpinPU x -> reduceSpinBy x (_prjID pj)
|
||||
DestroyPU mitid 0 -> destroyProjectile mitid (_prjID pj)
|
||||
@@ -156,14 +156,14 @@ 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 :: ProjectileHoming -> Projectile -> World -> World
|
||||
pjRemoteSetDirection :: Maybe ProjectileHoming -> Projectile -> World -> World
|
||||
pjRemoteSetDirection ph pj w = case ph of
|
||||
HomeUsingRemoteScreen screenid
|
||||
Just (HomeUsingRemoteScreen screenid)
|
||||
| lw ^? creatures . ix 0 . crManipulation . manObject . imSelectedItem
|
||||
== lw ^? itemLocations . ix (_unNInt screenid) . ilInvID ->
|
||||
w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjDir
|
||||
.~ (w ^. wCam . camRot) + argV (w ^. input . mousePos)
|
||||
HomeUsingTargeting itid
|
||||
Just (HomeUsingTargeting itid)
|
||||
| Just tp <- w ^? pointerToItemID itid . itTargeting . itTgPos . _Just ->
|
||||
w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjDir
|
||||
%~ turnTo 0.2 (_prjPos pj) tp
|
||||
@@ -171,16 +171,6 @@ pjRemoteSetDirection ph pj w = case ph of
|
||||
where
|
||||
lw = w ^. cWorld . lWorld
|
||||
|
||||
--pjRemoteSetDirection mscreenid pj w = fromMaybe w $ do
|
||||
-- screenid <- fmap _unNInt mscreenid
|
||||
-- let newdir
|
||||
-- | w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . imSelectedItem
|
||||
-- == w ^? cWorld . lWorld . itemLocations . ix screenid . ilInvID
|
||||
-- = (w ^. wCam . camRot) + argV (_mousePos (_input w))
|
||||
-- | otherwise = _prjDir pj
|
||||
-- turntonewdir = magV (_prjAcc pj) *.* unitVectorAtAngle newdir
|
||||
-- return $ w & cWorld . lWorld . projectiles . ix (_prjID pj) . prjAcc .~ turntonewdir
|
||||
|
||||
reduceSpinBy :: Float -> Int -> World -> World
|
||||
reduceSpinBy x pjid = cWorld . lWorld . projectiles . ix pjid . prjSpin *~ x
|
||||
|
||||
@@ -189,7 +179,6 @@ decTimMvVel pj =
|
||||
cWorld . lWorld . projectiles . ix pjid
|
||||
%~ ( (prjTimer -~ 1)
|
||||
. (prjPos %~ (+.+ vel))
|
||||
-- . (prjAcc %~ rotateV rot)
|
||||
. (prjDir +~ rot)
|
||||
)
|
||||
where
|
||||
@@ -207,7 +196,7 @@ explodeShell ::
|
||||
explodeShell controlid mdetid screenid pj w =
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjUpdates .~ [DestroyPU screenid 30]
|
||||
& cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
-- & cWorld . lWorld . projectiles . ix pjid . prjDraw .~ DrawBlankProjectile
|
||||
& usePayload (_prjPayload pj) (_prjPos pj) (_prjVel pj)
|
||||
& stopSoundFrom (ShellSound pjid)
|
||||
& updatedetonator
|
||||
|
||||
Reference in New Issue
Block a user