Refactor basic explosion

This commit is contained in:
2021-03-23 14:50:23 +01:00
parent 885fa4a67e
commit b13467053a
6 changed files with 32 additions and 61 deletions
+10 -10
View File
@@ -667,7 +667,7 @@ aTeslaArc' cid w =
$ over projectiles (IM.insert i (makeTeslaArcAt i pos dir))
$ set randGen g w
where cr = (_creatures w IM.! cid)
i = newParticleKey w
i = newProjectileKey w
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
+.+ sideOffset *.* vNormal (unitVectorAtAngle dir)
(sideOffset,g) = randomR (-5,5) $ _randGen w
@@ -679,7 +679,7 @@ aLaser cid w = over particles' ( (:) (makeLaserAt phaseV pos dir (Just cid)))
$ flareAt' yellow 0.02 0.05 (pos +.+ 5 *.* unitVectorAtAngle dir)
w
where cr = (_creatures w IM.! cid)
i = newParticleKey w
i = newProjectileKey w
pos = _crPos cr +.+ ((_crRad cr +3) *.* unitVectorAtAngle dir)
dir = _crDir cr
phaseV = fromMaybe 1 $ cr ^? crInv . ix j . itAttachment . _Just . itPhaseV
@@ -691,7 +691,7 @@ aTractorBeam col cid w
= set (creatures . ix cid . crInv . ix itRef . wpFire)
(shoot $ aTractorBeam ((col + 1) `mod` 10))
$ over projectiles (IM.insert i (tractorBeamAt col i pos dir)) w
where i = newParticleKey w
where i = newProjectileKey w
cr = (_creatures w IM.! cid)
pos = _crPos cr +.+ ((_crRad cr +10) *.* unitVectorAtAngle dir)
dir = _crDir cr
@@ -701,7 +701,7 @@ aRocket :: Int -> World -> World
aRocket cid w
= soundOnce (fromIntegral launcherSound)
$ over projectiles (IM.insert i (makeShellAt i cid pos dir)) w
where i = newParticleKey w
where i = newProjectileKey w
cr = (_creatures w IM.! cid)
pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
dir = _crDir cr
@@ -877,7 +877,7 @@ aFlame a cid w
pos2 = (0.5 *.* vel) +.+
_crPos cr +.+ ((_crRad cr + 2.9) *.* unitVectorAtAngle (_crDir cr))
w1 = set randGen g w
i = newParticleKey w1
i = newProjectileKey w1
-- vel = (_crPos cr -.- _crOldPos cr) +.+ 4 *.* unitVectorAtAngle dir
vel = (_crPos cr -.- _crOldPos cr) +.+ 4 *.* unitVectorAtAngle dir
insertFlame = makeFlame pos vel (Just cid) -- . makeFlame pos2 vel (Just cid)
@@ -1197,7 +1197,7 @@ withThickSmoke eff cid w = eff cid $ foldr ($) w smokeGen
makeThinSmokeAt :: Color -> Point2 -> Float -> Int -> Point2 -> World -> World
makeThinSmokeAt col vel scal time p w = over projectiles (IM.insert n smP) w
where n = newParticleKey w
where n = newProjectileKey w
smP = Projectile
{ _ptPos = p
, _ptStartPos = p
@@ -1400,7 +1400,7 @@ throwGrenade fuseTime n w = setWp $ removePict $ over projectiles addG $ set ran
}
j = _crInvSel $ _creatures w IM.! n
removePict = set (creatures . ix n . crInv . ix j . itEquipPict) $ \ _ _ -> blank
i = newParticleKey w
i = newProjectileKey w
(a, g) = randomR (-grenadeAccA,grenadeAccA::Float) (_randGen w)
(l, _) = randomR (1 - 2*grenadeAccL,1+grenadeAccL::Float) g
-- v = 0.02 * l / _cameraZoom w *.* rotateV (a+_cameraRot w) (limitRange $ _mousePos w)
@@ -1580,7 +1580,7 @@ throwRemoteBomb n w = setLocation $ removePict $ resetFire
, _ptID = i
, _ptUpdate = moveRemoteBomb itid 50 i
}
i = newParticleKey w
i = newProjectileKey w
-- fireDist = zoom *.* (rotateV (_cameraRot w) (_mousePos w) +.+ _cameraPos w -.- yourPos)
d = argV $ _mousePos w
--(l, _) = randomR (1 - grenadeAccL,1+grenadeAccL) (_randGen w)
@@ -1673,7 +1673,7 @@ moveTeslaArc p d i w =
f2 0 = cyan
f2 1 = azure
f2 _ = white
sID = newParticleKey w
sID = newProjectileKey w
q1 = last $ init ps'
q2 = last ps'
hitWall = collidePointWalls q1 ((2 *.* q2) -.- q1) $ wallsNearPoint q1 w
@@ -1863,7 +1863,7 @@ forceFieldFire cid w = w
-- (M.insert (_wpAmmoType item) newTotalA) w
-- | emptyCondition = soundOnce 1 w
-- | otherwise = w
-- where i = newParticleKey w
-- where i = newProjectileKey w
-- cr = (_creatures w IM.! n)
-- pos = _crPos cr +.+ ((_crRad cr +1) *.* unitVectorAtAngle dir)
-- dir = _crDir cr