This repository has been archived on 2026-07-13. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
servicepoint-tanks/TanksServer/GameLogic/CollideBulletsWithMap.cs
Vinzenz Schroeter dec571d8c1 destructible walls
2024-04-16 18:55:34 +02:00

20 lines
510 B
C#

namespace TanksServer.GameLogic;
internal sealed class CollideBulletsWithMap(BulletManager bullets, MapService map) : ITickStep
{
public Task TickAsync()
{
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;
}
}