Move bullets into own data type

This commit is contained in:
2022-07-16 21:15:25 +01:00
parent 22adcb89e0
commit 301946ff8f
21 changed files with 216 additions and 108 deletions
+9 -5
View File
@@ -42,20 +42,24 @@ applyDamageEffect dm de cr w = case de of
& creatures . ix (_crID cr) . crPos .+.+~ (1/_crMass cr) *.* pback
TorqueDamage rot -> w
& creatures . ix (_crID cr) . crDir +~ rot
BounceBullet bt | crIsArmouredFrom p cr -> w & instantParticles .:~ bouncer
BounceBullet bt | crIsArmouredFrom p cr -> w & instantBullets .:~ bouncer
where
bouncer = (aBulAt Nothing id (Just (_ptColor bt)) pOut reflectVel (_btDrag bt)
(_ptHitEff bt) (_ptWidth bt)
) {_ptTimer = _ptTimer bt - 1}
bouncer = (aBulAt Nothing id (Just (_buColor bt)) pOut reflectVel (_buDrag bt)
(_buHitEff bt) (_buWidth bt)
) {_buTimer = _buTimer bt - 1}
pOut = p +.+ 2 *.* newDir
reflectVel = magV bulVel *.* newDir
newDir = squashNormalizeV (p -.- _crPos cr)
bulVel = _ptVel bt
bulVel = _buVel bt
BounceBullet _ -> w
DamageSpawn f -> w & instantParticles .:~ thepart
& randGen .~ g
where
(thepart,g) = runState (f (Left cr) dm) $ _randGen w
DamageSpawn' f -> w & instantBullets .:~ thepart
& randGen .~ g
where
(thepart,g) = runState (f (Left cr) dm) $ _randGen w
NoDamageEffect -> w
where
fromDir = _dmFrom dm