示例#1
0
        public static void WriteSwarm(IEnumerable <EncounterArea3> area, string name, string ident = "g3")
        {
            var serialized = area.Select(WriteSwarm).ToArray();
            var packed     = BinLinker.Pack(serialized, ident);

            File.WriteAllBytes(name, packed);
        }
        public static void DumpGen7b()
        {
            EncounterArea7b[] SlotsGP = EncounterArea7b.GetAreas(Get(Properties.Resources.encounter_gp, "gg"));
            EncounterArea7b[] SlotsGE = EncounterArea7b.GetAreas(Get(Properties.Resources.encounter_ge, "gg"));
            ManuallyAddRareSpawns(SlotsGP);
            ManuallyAddRareSpawns(SlotsGE);

            var gp = SlotsGP.Select(z => z.WriteSlots()).ToArray();
            var ge = SlotsGE.Select(z => z.WriteSlots()).ToArray();

            File.WriteAllBytes("encounter_gp.pkl", BinLinker.Pack(gp, "gg"));
            File.WriteAllBytes("encounter_ge.pkl", BinLinker.Pack(ge, "gg"));
        }
示例#3
0
        public static void Write(IEnumerable <EncounterArea3> area, string name, string ident = "g3")
        {
            var           serialized = area.Select(Write).ToArray();
            List <byte[]> unique     = new List <byte[]>();

            foreach (var a in serialized)
            {
                if (unique.Any(z => z.SequenceEqual(a)))
                {
                    continue;
                }
                unique.Add(a);
            }

            var packed = BinLinker.Pack(unique.ToArray(), ident);

            File.WriteAllBytes(name, packed);
            Console.WriteLine($"Wrote {name} with {unique.Count} unique tables (originally {serialized.Length}).");
        }
示例#4
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()));
        }
示例#5
0
        public static void MineGen5()
        {
            // Load in unpacked NARCs
            byte[] zd51 = File.ReadAllBytes("zd51");
            byte[] zd52 = File.ReadAllBytes("zd52");

            byte[][] eW1 = Directory.GetFiles("eW1").Select(File.ReadAllBytes).ToArray();
            byte[][] eW2 = Directory.GetFiles("eW2").Select(File.ReadAllBytes).ToArray();
            byte[][] eB1 = Directory.GetFiles("eB1").Select(File.ReadAllBytes).ToArray();
            byte[][] eB2 = Directory.GetFiles("eB2").Select(File.ReadAllBytes).ToArray();

            byte[][] edW1 = Reserialize(zd51, eW1, SIZE_ZD51);
            byte[][] edW2 = Reserialize(zd52, eW2, SIZE_ZD52);
            byte[][] edB1 = Reserialize(zd51, eB1, SIZE_ZD51);
            byte[][] edB2 = Reserialize(zd52, eB2, SIZE_ZD52);

            File.WriteAllBytes("encounter_w.pkl", BinLinker.Pack(edW1, "51"));
            File.WriteAllBytes("encounter_b.pkl", BinLinker.Pack(edB1, "51"));
            File.WriteAllBytes("encounter_w2.pkl", BinLinker.Pack(edW2, "52"));
            File.WriteAllBytes("encounter_b2.pkl", BinLinker.Pack(edB2, "52"));
        }
示例#6
0
        public static void DumpGen3()
        {
            var r = Resources.encounter_r;
            var s = Resources.encounter_s;
            var e = Resources.encounter_e;

            var f = Resources.encounter_fr;
            var l = Resources.encounter_lg;

            var ru = EncounterArea3.GetArray3(BinLinker.Unpack(r, "ru"));
            var sa = EncounterArea3.GetArray3(BinLinker.Unpack(s, "sa"));
            var em = EncounterArea3.GetArray3(BinLinker.Unpack(e, "em"));

            EncounterUtil.MarkEncountersStaticMagnetPull <EncounterSlot3>(em, PersonalTable.E);

            var fr = EncounterArea3.GetArray3(BinLinker.Unpack(f, "fr"));
            var lg = EncounterArea3.GetArray3(BinLinker.Unpack(l, "lg"));

            // Remove unreleased Altering Cave tables
            fr = fr.Where(z => z.Location != 183 || z.Slots[0].Species == (int)Species.Zubat).ToArray();
            lg = lg.Where(z => z.Location != 183 || z.Slots[0].Species == (int)Species.Zubat).ToArray();

            var rd = ru.Concat(FishFeebas).OrderBy(z => z.Location).ThenBy(z => z.Type);
            var sd = sa.Concat(FishFeebas).OrderBy(z => z.Location).ThenBy(z => z.Type);
            var ed = em.Concat(FishFeebas).OrderBy(z => z.Location).ThenBy(z => z.Type);

            var fd = fr.Concat(SlotsFRLGUnown).OrderBy(z => z.Location).ThenBy(z => z.Type);
            var ld = lg.Concat(SlotsFRLGUnown).OrderBy(z => z.Location).ThenBy(z => z.Type);

            Write(rd, "encounter_r.pkl", "ru");
            Write(sd, "encounter_s.pkl", "sa");
            Write(ed, "encounter_e.pkl", "em");
            Write(fd, "encounter_fr.pkl", "fr");
            Write(ld, "encounter_lg.pkl", "lg");

            WriteSwarm(SlotsRSEAlt, "encounter_rse_swarm.pkl", "rs");
        }
示例#7
0
            static EncounterArea5[] GetEncounterTables(string ident, byte[] mini)
            {
                var data = BinLinker.Unpack(mini, ident);

                return(EncounterArea32.GetArray <EncounterArea5, EncounterSlot5>(data));
            }
 private static byte[][] Get(byte[] data, string ident) => BinLinker.Unpack(data, ident);
        private static void PackUnique(List <byte[]> unique, string name, string ident)
        {
            var packed = BinLinker.Pack(unique.ToArray(), ident);

            File.WriteAllBytes(name, packed);
        }