Make examine inventory controlled by item, perhaps still buggy
This commit is contained in:
@@ -3,49 +3,56 @@ module Dodge.Projectile.Create (
|
||||
PJStabiliser (..),
|
||||
) where
|
||||
|
||||
import NewInt
|
||||
--import Dodge.Data.ComposedItem
|
||||
--import Dodge.Data.DoubleTree
|
||||
import Dodge.Item.Location
|
||||
|
||||
import Data.Maybe
|
||||
import Dodge.Data.World
|
||||
import Dodge.Item.Location
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import NewInt
|
||||
|
||||
data PJStabiliser
|
||||
= StabOrthReduce
|
||||
| StabSpinIncrease
|
||||
|
||||
|
||||
-- assumes the mscreen is in your inventory
|
||||
createShell ::Maybe (NewInt ItmInt)
|
||||
-> Maybe (NewInt ItmInt)
|
||||
-> Maybe PJStabiliser
|
||||
-> ProjectileType
|
||||
-> Payload -> Muzzle -> Creature -> World -> World
|
||||
createShell mdetonator mscreen stab pjtype payload muz cr w = w
|
||||
& updatescreen
|
||||
& updatedetonator
|
||||
& cWorld . lWorld . projectiles . at i
|
||||
?~ Shell
|
||||
{ _pjPos = pos
|
||||
, _pjZ = 20
|
||||
, _pjZVel = 5
|
||||
, _pjVel = rotateV dir (V2 speed 0) + crvelcomponent
|
||||
, _pjID = i
|
||||
, _pjDir = dir
|
||||
, _pjSpin = 0
|
||||
, _pjPayload = payload
|
||||
, _pjTimer = lifespan
|
||||
, _pjUpdates =
|
||||
anyspin <>
|
||||
[ RemoteDirectionPU (lifespan - thrustdelay) 0
|
||||
] <> thrustorgrav
|
||||
, _pjType = pjtype
|
||||
, _pjDetonatorID = mdetonator
|
||||
, _pjScreenID = mscreen
|
||||
}
|
||||
createShell ::
|
||||
Maybe (NewInt ItmInt) ->
|
||||
Maybe (NewInt ItmInt) ->
|
||||
Maybe PJStabiliser ->
|
||||
ProjectileType ->
|
||||
Payload ->
|
||||
Muzzle ->
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
createShell mdetonator mscreen stab pjtype payload muz cr w =
|
||||
w
|
||||
& updatescreen
|
||||
& updatedetonator
|
||||
& cWorld . lWorld . projectiles . at i
|
||||
?~ Shell
|
||||
{ _pjPos = pos
|
||||
, _pjZ = 20
|
||||
, _pjZVel = 5
|
||||
, _pjVel = rotateV dir (V2 speed 0) + crvelcomponent
|
||||
, _pjID = i
|
||||
, _pjDir = dir
|
||||
, _pjSpin = 0
|
||||
, _pjPayload = payload
|
||||
, _pjTimer = lifespan
|
||||
, _pjUpdates =
|
||||
anyspin
|
||||
<> [ RemoteDirectionPU (lifespan - thrustdelay) 0
|
||||
]
|
||||
<> thrustorgrav
|
||||
, _pjType = pjtype
|
||||
, _pjDetonatorID = mdetonator
|
||||
, _pjScreenID = mscreen
|
||||
}
|
||||
where
|
||||
crvelcomponent = case stab of
|
||||
Just StabOrthReduce -> projV (cr ^. crPos - cr ^. crOldPos) (unitVectorAtAngle dir)
|
||||
@@ -55,27 +62,27 @@ createShell mdetonator mscreen stab pjtype payload muz cr w = w
|
||||
Just StabSpinIncrease -> [StartSpinPU (lifespan - 15) (_crID cr) 4]
|
||||
_ -> [StartSpinPU (lifespan - 15) (_crID cr) 2]
|
||||
speed = case pjtype of
|
||||
Grenade {} -> 4
|
||||
Grenade{} -> 4
|
||||
Rocket{} -> 1
|
||||
RetiredProjectile -> 0
|
||||
lifespan = 350
|
||||
thrustorgrav = case pjtype of
|
||||
Grenade {}-> []
|
||||
Grenade{} -> []
|
||||
Rocket{} -> [ThrustPU (lifespan - thrustdelay) 0]
|
||||
RetiredProjectile -> []
|
||||
thrustdelay = 20
|
||||
updatedetonator = fromMaybe id $ do
|
||||
screenid <- mdetonator
|
||||
return $ pointerToItemID screenid . itUse . uaParams
|
||||
return $
|
||||
pointerToItemID screenid . itUse . uaParams
|
||||
. apProjectiles
|
||||
.:~ i
|
||||
updatescreen = fromMaybe id $ do
|
||||
screenid <- mscreen
|
||||
return $ pointerToItemID screenid . itUse . uaParams
|
||||
return $
|
||||
pointerToItemID screenid . itUse . uaParams
|
||||
. apProjectiles
|
||||
.:~ i
|
||||
-- . apLinkedProjectile
|
||||
-- ?~ i
|
||||
i = IM.newKey $ w ^. cWorld . lWorld . projectiles
|
||||
dir = _crDir cr + _mzRot muz
|
||||
pos = _crPos cr +.+ rotateV dir (_mzPos muz)
|
||||
|
||||
@@ -42,14 +42,15 @@ upProjectile pj pu = case pu of
|
||||
RemoteDirectionPU st et
|
||||
| act st et -> pjRemoteSetDirection (pj ^? pjType . rkHoming) pj
|
||||
| otherwise -> id
|
||||
-- ApplyGravityPU -> applyGravityPU pj
|
||||
where
|
||||
-- ApplyGravityPU -> applyGravityPU pj
|
||||
|
||||
time = _pjTimer pj
|
||||
act st et = time <= st && time >= et
|
||||
|
||||
doGravityPU :: Projectile -> World -> World
|
||||
doGravityPU pj
|
||||
| Grenade GBounce {} <- pj ^. pjType = applyGravityPU pj
|
||||
| Grenade GBounce{} <- pj ^. pjType = applyGravityPU pj
|
||||
| Grenade GStick <- pj ^. pjType = applyGravityPU pj
|
||||
| otherwise = id
|
||||
|
||||
@@ -106,14 +107,16 @@ tryShellBounce :: (Point2, Either Creature Wall) -> Projectile -> World -> World
|
||||
tryShellBounce (p, Right wl) pj w
|
||||
| Just GStuckCreature{} <- pj ^? pjType . gnHitEffect = w
|
||||
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w
|
||||
| Just GStick <- pj ^? pjType . gnHitEffect = w
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjType
|
||||
.~ Grenade (GStuckWall (wl ^. wlStructure))
|
||||
-- & cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
|
||||
& soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos)
|
||||
| Just GStick <- pj ^? pjType . gnHitEffect =
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjType
|
||||
.~ Grenade (GStuckWall (wl ^. wlStructure))
|
||||
-- & cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
|
||||
& soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos)
|
||||
| Just x <- pj ^? pjType . gnHitEffect . bounceTolerance =
|
||||
if abs (dotV (pj ^. pjVel) (vNormal hitline)) < x
|
||||
then w
|
||||
then
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjVel
|
||||
%~ reflectIn hitline
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjPos .~ p
|
||||
@@ -124,16 +127,17 @@ tryShellBounce (p, Right wl) pj w
|
||||
tryShellBounce (p, Left cr) pj w
|
||||
| Just GStuckCreature{} <- pj ^? pjType . gnHitEffect = w
|
||||
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w
|
||||
| Just GStick <- pj ^? pjType . gnHitEffect = w
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjType
|
||||
.~ Grenade
|
||||
(GStuckCreature
|
||||
(cr ^. crID)
|
||||
(rotateV (- cr ^. crDir) (p - cr ^. crPos))
|
||||
(pj ^. pjDir - cr ^. crDir)
|
||||
)
|
||||
-- & cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
|
||||
& soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos)
|
||||
| Just GStick <- pj ^? pjType . gnHitEffect =
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjType
|
||||
.~ Grenade
|
||||
( GStuckCreature
|
||||
(cr ^. crID)
|
||||
(rotateV (- cr ^. crDir) (p - cr ^. crPos))
|
||||
(pj ^. pjDir - cr ^. crDir)
|
||||
)
|
||||
-- & cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
|
||||
& soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos)
|
||||
tryShellBounce _ pj w = explodeShell pj w
|
||||
|
||||
destroyProjectile :: Maybe (NewInt ItmInt) -> Int -> World -> World
|
||||
@@ -209,16 +213,17 @@ pjRemoteSetDirection ph pj w = case ph of
|
||||
pjMovement :: Projectile -> World -> World
|
||||
pjMovement pj w
|
||||
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w
|
||||
| Just (GStuckCreature crid p d) <- pj ^? pjType . gnHitEffect = fromMaybe
|
||||
(w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjType .~ Grenade GStick)
|
||||
| Just (GStuckCreature crid p d) <- pj ^? pjType . gnHitEffect = fromMaybe
|
||||
(w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjType .~ Grenade GStick)
|
||||
$ do
|
||||
cpos <- w ^? cWorld . lWorld . creatures . ix crid . crPos
|
||||
cdir <- w ^? cWorld . lWorld . creatures . ix crid . crDir
|
||||
return $
|
||||
w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos
|
||||
.~ cpos + rotateV cdir p
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir
|
||||
.~ d + cdir
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos
|
||||
.~ cpos + rotateV cdir p
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir
|
||||
.~ d + cdir
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjSpin *~ 0.99
|
||||
|
||||
Reference in New Issue
Block a user