add bullet timeout
This commit is contained in:
parent
61f90b99af
commit
0aac6f780b
1 changed files with 20 additions and 3 deletions
|
|
@ -13,9 +13,20 @@ internal sealed class CollideBullets(
|
|||
{
|
||||
entityManager.RemoveBulletsWhere(BulletHitsTank);
|
||||
entityManager.RemoveBulletsWhere(TryHitAndDestroyWall);
|
||||
entityManager.RemoveBulletsWhere(TimeoutBullet);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private bool TimeoutBullet(Bullet bullet)
|
||||
{
|
||||
if (bullet.Timeout > DateTime.Now)
|
||||
return false;
|
||||
|
||||
var radius = bullet.IsExplosive ? ExplosionRadius : 0;
|
||||
ExplodeAt(bullet.Position.ToPixelPosition(), radius, bullet.Owner);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryHitAndDestroyWall(Bullet bullet)
|
||||
{
|
||||
var pixel = bullet.Position.ToPixelPosition();
|
||||
|
|
|
|||
Reference in a new issue