Exemplo n.º 1
0
        public static void Dump()
        {
            var raw     = Resources.trees_h_c;
            var entries = BinLinker.Unpack(raw, "ch");
            var t       = TreesArea.GetArray(entries);

            var lines  = Resources.text_gsc_00000_en.Split('\n');
            var result = t.SelectMany(z => z.DumpLocation(lines));

            File.WriteAllLines("trees.txt", result);

            var opt = new JsonSerializerOptions {
                ReadCommentHandling = JsonCommentHandling.Skip, AllowTrailingCommas = true
            };
            var json    = Resources.trees;
            var listing = JsonSerializer.Deserialize <TreeAreaListing>(json, opt);

            var tables = new List <TreeInfo>();

            foreach (var l in listing !.Table)
            {
                var info = new TreeInfo(l.Location);
                foreach (var tree in l.Valid)
                {
                    info.Add(tree);
                }

                tables.Add(info);
            }

            using var ms = new MemoryStream();
            using var bw = new BinaryWriter(ms);
            foreach (var info in tables)
            {
                bw.Write(info.Write());
            }

            var flat = ms.ToArray();

            File.WriteAllBytes("trees.bin", flat);
            File.WriteAllLines("tree_dict.txt", tables.Select(z => z.WriteString()));
        }