Пример #1
0
    static void MapData(IAssetManager assets, string baseDir, AssetId[] dumpIds)
    {
        using var sw = Open(baseDir, MapInfoPath);
        for (int i = 100; i < 400; i++)
        {
            MapId id = MapId.From((Base.Map)i);
            if (dumpIds != null && !dumpIds.Contains(id))
            {
                continue;
            }

            IMapData map = assets.LoadMap(id);
            if (map == null)
            {
                continue;
            }

            sw.Write($"{i} {(Base.Map)i} {map.MapType} ");
            sw.Write($"{map.Width}x{map.Height} ");
            sw.Write($"Palette:{map.PaletteId} ({map.PaletteId.Id}) ");
            if (map is MapData2D map2d)
            {
                sw.Write($"FrameRate:{map2d.FrameRate} ");
                sw.Write($"TileSet:{map2d.TilesetId} ");
                sw.Write($"Flags:{map2d.Flags} ");
                sw.Write($"Sound?:{map2d.Sound} ");
            }

            LabyrinthData lab = null;
            if (map is MapData3D map3d)
            {
                sw.Write($"Flags: {map3d.Flags} ");
                sw.Write($"Labyrinth: {map3d.LabDataId} ");
                sw.Write($"Sound?:{map3d.AmbientSongId} ");
                lab = assets.LoadLabyrinthData(map3d.LabDataId);
            }

            sw.Write($"Song:{map.SongId} ({map.SongId.Id}) ");
            sw.WriteLine($"CombatBackground:{map.CombatBackgroundId} ({map.CombatBackgroundId.Id})");

            for (int j = 0; j < map.Npcs.Count; j++)
            {
                var npc = map.Npcs[j];
                if (npc == null)
                {
                    continue;
                }

                var wp     = npc.Waypoints.FirstOrDefault();
                var idText = npc.Id.ToString().PadLeft(15);

                sw.Write($"    Npc{j:D3}: {idText} ({npc.Id.Id:D3}) ");
                sw.Write($"X:{wp.X:D3} Y:{wp.Y:D3} ");
                sw.Write($"F{(int)npc.Flags:X2}:({npc.Flags}) ");
                sw.Write($"M:{npc.Movement} ");
                sw.Write($"S:{npc.Sound} ({npc.Sound}) ");
                switch (map.MapType)
                {
                case MapType.TwoD: sw.Write($"GR:{npc.SpriteOrGroup} "); break;

                case MapType.TwoDOutdoors: sw.Write($"KL:{npc.SpriteOrGroup} "); break;

                case MapType.ThreeD:
                    if (lab != null)
                    {
                        if (npc.SpriteOrGroup.Id >= lab.ObjectGroups.Count)
                        {
                            sw.Write($"InvalidObjGroup:{npc.SpriteOrGroup.Id}");
                        }
                        else
                        {
                            var objectData = lab.ObjectGroups[npc.SpriteOrGroup.Id];
                            sw.Write($"3D:{npc.SpriteOrGroup.Id}=(");
                            bool first = true;
                            foreach (var subObject in objectData.SubObjects)
                            {
                                if (subObject == null)
                                {
                                    continue;
                                }
                                if (!first)
                                {
                                    sw.Write(", ");
                                }
                                first = false;
                                var def = lab.Objects[subObject.ObjectInfoNumber];
                                sw.Write(def.SpriteId);
                            }

                            sw.Write(")");
                        }
                    }

                    break;
                }

                sw.WriteLine();
                if (npc.Chain != 0xffff)
                {
                    sw.WriteLine($"        EventChain: {npc.Chain}");
                    var formatter = new EventFormatter(assets.LoadString, id.ToMapText());
                    sw.WriteLine(formatter.FormatChain(npc.Node, 2));
                }
            }
            sw.WriteLine();
        }
    }