Beispiel #1
0
        public static MapInfo[] ReadAll(IFileReader fs, BdatCollection tables)
        {
            Dictionary <string, MapInfo> maps = MapInfo.ReadAll(fs);

            var mapList  = tables.FLD_maplist;
            var areaList = tables.MNU_MapInfo;

            foreach (MapInfo mapInfo in maps.Values)
            {
                var map = mapList.FirstOrDefault(x => x.resource == mapInfo.Name && x._nameID != null);
                if (map == null)
                {
                    continue;
                }
                if (map._nameID != null)
                {
                    mapInfo.DisplayName = map._nameID.name;
                }

                foreach (var areaInfo in mapInfo.Areas)
                {
                    MNU_MapInfo area = areaList.FirstOrDefault(x =>
                                                               x.level_name == areaInfo.Name || x.level_name2 == areaInfo.Name);
                    Debug.Assert(area != null, "Area does not exist");

                    // Some areas use one of 2 maps depending on the game state.
                    // These 2 maps are always the same except one has a small addition or removal.
                    // We want the map with the most objects on it, so we use the second map for
                    // Gormott (ma05a), and the first map for everywhere else.
                    if (!string.IsNullOrWhiteSpace(area.level_name2) &&
                        area.level_name == areaInfo.Name &&
                        mapInfo.Name == "ma05a")
                    {
                        areaInfo.Priority = int.MaxValue;
                    }
                    else if (!string.IsNullOrWhiteSpace(area.level_name2) &&
                             area.level_name2 == areaInfo.Name &&
                             mapInfo.Name != "ma05a")
                    {
                        areaInfo.Priority = int.MaxValue;
                    }
                    else
                    {
                        areaInfo.Priority = area.level_priority;
                    }

                    if (area._disp_name?.name != null)
                    {
                        areaInfo.DisplayName = area._disp_name.name;
                    }
                }

                var gimmickSet = ReadGimmickSet(fs, tables, map.Id);
                AssignGimmickAreas(gimmickSet, mapInfo);
            }

            return(maps.Values.ToArray());
        }
Beispiel #2
0
        public static MapInfo[] ReadAll(IFileSystem fs, BdatCollection tables, IProgressReport progress = null)
        {
            progress?.LogMessage("Reading map info and gimmick sets");
            Dictionary <string, MapInfo> maps = MapInfo.ReadAll(fs);

            BdatTable <FLD_maplist> mapList  = tables.FLD_maplist;
            BdatTable <MNU_MapInfo> areaList = tables.MNU_MapInfo;

            foreach (MapInfo mapInfo in maps.Values)
            {
                FLD_maplist map = mapList.FirstOrDefault(x => x.resource == mapInfo.Name && x._nameID != null);
                if (map == null)
                {
                    continue;
                }
                if (map._nameID != null)
                {
                    mapInfo.DisplayName = map._nameID.name;
                }

                foreach (MapAreaInfo areaInfo in mapInfo.Areas)
                {
                    MNU_MapInfo area = areaList.FirstOrDefault(x =>
                                                               x.level_name == areaInfo.Name || x.level_name2 == areaInfo.Name);
                    if (area == null)
                    {
                        progress?.LogMessage($"Found area {areaInfo.Name} that is not in the BDAT tables");
                        continue;
                    }

                    // Some areas use one of 2 maps depending on the game state.
                    // These 2 maps are always the same except one has a small addition or removal.
                    // We want the map with the most objects on it, so we use the second map for
                    // Gormott (ma05a), and the first map for everywhere else.
                    if (!string.IsNullOrWhiteSpace(area.level_name2) &&
                        area.level_name == areaInfo.Name &&
                        mapInfo.Name == "ma05a")
                    {
                        areaInfo.Priority = int.MaxValue;
                    }
                    else if (!string.IsNullOrWhiteSpace(area.level_name2) &&
                             area.level_name2 == areaInfo.Name &&
                             mapInfo.Name != "ma05a")
                    {
                        areaInfo.Priority = int.MaxValue;
                    }
                    else
                    {
                        areaInfo.Priority = area.level_priority;
                    }

                    if (area._disp_name?.name != null)
                    {
                        areaInfo.DisplayName = area._disp_name.name;
                    }
                }

                Dictionary <string, Lvb> gimmickSet = ReadGimmickSet(fs, tables, map.Id);
                AssignGimmickAreas(gimmickSet, mapInfo);
            }

            return(maps.Values.ToArray());
        }