BattleInfoPlugin.ViewModels.EnemyWindowViewModel.CreateEnemyCells C# (CSharp) Method

CreateEnemyCells() private static method

private static CreateEnemyCells ( BattleInfoPlugin.Models.MapInfo mi, FleetData>.IReadOnlyDictionary mapEnemies, CellType>.IReadOnlyDictionary cellTypes ) : BattleInfoPlugin.ViewModels.Enemies.EnemyCellViewModel[]
mi BattleInfoPlugin.Models.MapInfo
mapEnemies FleetData>.IReadOnlyDictionary
cellTypes CellType>.IReadOnlyDictionary
return BattleInfoPlugin.ViewModels.Enemies.EnemyCellViewModel[]
        private static EnemyCellViewModel[] CreateEnemyCells(
            MapInfo mi,
            IReadOnlyDictionary<MapInfo, Dictionary<MapCell, Dictionary<string, FleetData>>> mapEnemies,
            IReadOnlyDictionary<MapCell, CellType> cellTypes)
        {
            return MapResource.HasMapSwf(mi)
                ? MapResource.GetMapCellPoints(mi) //マップSWFがあったらそれを元に作る
                                                   //外部結合
                    .GroupJoin(
                        CreateMapCellViewModelsFromEnemiesData(mi, mapEnemies, cellTypes),
                        outer => outer.Key,
                        inner => inner.Key,
                        (o, ie) => new { point = o, cells = ie })
                    .SelectMany(
                        x => x.cells.DefaultIfEmpty(),
                        (x, y) => new { x.point, cells = y })
                    //座標マージ
                    .GroupBy(x => x.point.Value)
                    .Select(x => new EnemyCellViewModel
                    {
                        Key = x.Min(y => y.point.Key), //若い番号を採用
                        EnemyFleets = x.Where(y => y.cells != null) //敵データをEnemyIdでマージ
                            .SelectMany(y => y.cells.EnemyFleets)
                            .SelectMany(y => y.Fleets)
                            .MergeEnemies(),
                        ColorNo = x.Where(y => y.cells != null).Select(y => y.cells.ColorNo).FirstOrDefault(),
                        CellType = x.Where(y => y.cells != null).Select(y => y.cells.CellType).FirstOrDefault(),
                    })
                    //敵データのないセルは除外
                    .Where(x => x.EnemyFleets.Any())
                    .ToArray()
                : CreateMapCellViewModelsFromEnemiesData(mi, mapEnemies, cellTypes).ToArray();  //なかったら敵データだけ(重複るが仕方ない)
        }