Unify launcher projectile creation

This commit is contained in:
2024-12-27 21:52:18 +00:00
parent 5c749bff63
commit b6ece953c8
2 changed files with 6 additions and 92 deletions
+1 -56
View File
@@ -1,6 +1,5 @@
module Dodge.Projectile.Create (
-- createShell,
createGShell,
createShell,
) where
import NewInt
@@ -27,59 +26,6 @@ createShell :: ProjectileHoming
-> ProjectileType
-> Payload -> Muzzle -> Creature -> World -> World
createShell homing mdetonator mscreen smokestatus pjtype payload muz cr w = w
& updatescreen
& updatedetonator
& cWorld . lWorld . projectiles . at i
?~ Shell
{ _prjPos = pos
, _prjZ = 20
, _prjZVel = 0
, _prjVel = rotateV dir (V2 1 0) + cr ^. crPos - cr ^. crOldPos
, _prjDraw = homingDrawType homing
, _prjID = i
, _prjAcc = rotateV dir (V2 3 0)
, _prjDir = dir
, _prjSpin = 0
, _prjPayload = payload
, _prjTimer = lifespan
, _prjUpdates =
[ CollisionEffectPU (homing ^? phRemoteID) mdetonator mscreen
, TimePU
, StartSpinPU 335 (_crID cr) spinamount
, RemoteDirectionPU (lifespan - thrustdelay) 0 homing
, ThrustPU (lifespan - thrustdelay) 0 smokestatus
, ReduceSpinPU (1 - spindrag * 2 / 200)
]
, _prjType = pjtype
}
where
lifespan = 350
spindrag = 1
spinamount = 2
thrustdelay = 20
updatedetonator = fromMaybe id $ do
screenid <- mdetonator
return $ pointerToItemID screenid . itUse . uaParams
. apProjectiles
.:~ i
updatescreen = fromMaybe id $ do
--screenid <- homing ^? phRemoteID
screenid <- mscreen
return $ pointerToItemID screenid . itUse . uaParams
. apLinkedProjectile
?~ i
i = IM.newKey $ w ^. cWorld . lWorld . projectiles
dir = _crDir cr + _mzRot muz
pos = _crPos cr +.+ rotateV dir (_mzPos muz)
-- assumes the mscreen is in your inventory
createGShell :: ProjectileHoming
-> Maybe (NewInt ItmInt)
-> Maybe (NewInt ItmInt)
-> Bool
-> ProjectileType
-> Payload -> Muzzle -> Creature -> World -> World
createGShell homing mdetonator mscreen smokestatus pjtype payload muz cr w = w
& updatescreen
& updatedetonator
& cWorld . lWorld . projectiles . at i
@@ -123,7 +69,6 @@ createGShell homing mdetonator mscreen smokestatus pjtype payload muz cr w = w
. apProjectiles
.:~ i
updatescreen = fromMaybe id $ do
--screenid <- homing ^? phRemoteID
screenid <- mscreen
return $ pointerToItemID screenid . itUse . uaParams
. apLinkedProjectile