public static void RemoveTowers(this GameLevel level) { foreach (var tower in EntitiesRunner.Current.GetEntitiesOfType <Tower>()) { var towerMapPos = level.GetMapCoordinates(tower.Position.GetVector2D()); var index = level.GetIndexForMapData(towerMapPos); if (index >= level.MapData.Length) { return; } level.MapData[index] = LevelTileType.Placeable; level.GetPathFinding().SetReachableAndUpdate(index); tower.Dispose(); } }