fix destroyed walls count too high

This commit is contained in:
Vinzenz Schroeter 2024-04-21 19:34:22 +02:00
parent 3d69f592f6
commit 6045de0c7d
2 changed files with 8 additions and 5 deletions

View file

@ -76,11 +76,8 @@ internal sealed class CollideBullets(
for (var y = pixel.Y - i; y <= pixel.Y + i; y++)
{
var offsetPixel = new PixelPosition(x, y);
if (options.Value.DestructibleWalls)
{
map.Current.DestroyWallAt(offsetPixel);
if (options.Value.DestructibleWalls && map.Current.TryDestroyWallAt(offsetPixel))
owner.Scores.WallsDestroyed++;
}
TryHitTankAt(offsetPixel.ToFloatPosition(), owner);
}

View file

@ -104,5 +104,11 @@ internal sealed class Map(string name, bool[,] walls)
return false;
}
public void DestroyWallAt(PixelPosition pixel) => walls[pixel.X, pixel.Y] = false;
public bool TryDestroyWallAt(PixelPosition pixel)
{
var result = walls[pixel.X, pixel.Y];
if (result)
walls[pixel.X, pixel.Y] = false;
return result;
}
}