servicepoint-tanks/TanksServer/GameLogic/CollideBulletsWithMap.cs
Vinzenz Schroeter e16d4b1c1f delta time
2024-04-16 19:40:08 +02:00

21 lines
520 B
C#

namespace TanksServer.GameLogic;
internal sealed class CollideBulletsWithMap(BulletManager bullets, MapService map) : ITickStep
{
public Task TickAsync(TimeSpan _)
{
bullets.RemoveWhere(TryHitAndDestroyWall);
return Task.CompletedTask;
}
private bool TryHitAndDestroyWall(Bullet bullet)
{
var pixel = bullet.Position.ToPixelPosition();
if (!map.Current.IsWall(pixel))
return false;
map.Current.DestroyWallAt(pixel);
return true;
}
}