Esempio n. 1
0
        public override Character Read(BinaryReader reader)
        {
            var stats  = ComplexSerializer.Read <Statistics>(reader);
            var worlds = new Dictionary <long, WorldData>();

            foreach (var world in ComplexSerializer.ReadCollection <WorldData>(reader))
            {
                if (world.MapData != null &&
                    world.MapData.Length > 0)
                {
                    ReadMapData(world, world.MapData);
                }

                world.MapData = null;
                worlds.Add(world.WorldId, world);
            }

            var character = ComplexSerializer.Read <Character>(reader);

            var hasPlayerData = TypeSerializer.Read <bool>(reader);

            if (hasPlayerData)
            {
                var pd = TypeSerializer.ReadBytes(reader);
                ReadPlayerData(character, pd);
            }

            character.Statistics = stats;
            character.WorldData  = worlds;

            return(character);
        }
Esempio n. 2
0
        public void ReadMapData(WorldData world, byte[] data)
        {
            using var ms = new MemoryStream(data);
            using var br = new BinaryReader(ms);

            world.MapVersion = br.ReadInt32();
            var size = br.ReadInt32();

            world.Explored = new bool[size, size];

            for (var x = 0; x < size; x++)
            {
                for (var y = 0; y < size; y++)
                {
                    world.Explored[x, y] = br.ReadBoolean();
                }
            }

            world.Pins = ComplexSerializer
                         .ReadCollection <Pin>(br)
                         .ToList();
        }
Esempio n. 3
0
        public void ReadPlayerData(Character character, byte[] data)
        {
            using var ms = new MemoryStream(data);
            using var br = new BinaryReader(ms);

            character.PlayerData = ComplexSerializer.Read <PlayerData>(br);

            character.Inventory = ComplexSerializer
                                  .ReadCollection <Item>(br)
                                  .ToList();

            character.KnownRecipes = ComplexSerializer
                                     .ReadCollection <IndexedTuple <string> >(br)
                                     .FromIndexed()
                                     .ToList();

            character.KnownStations = ComplexSerializer
                                      .ReadCollection <IndexedTuple <string, int> >(br)
                                      .FromIndexed()
                                      .ToList();

            character.KnownMaterials = ComplexSerializer
                                       .ReadCollection <IndexedTuple <string> >(br)
                                       .FromIndexed()
                                       .ToList();

            character.KnownTutorials = ComplexSerializer
                                       .ReadCollection <IndexedTuple <string> >(br)
                                       .FromIndexed()
                                       .ToList();

            character.Uniques = ComplexSerializer
                                .ReadCollection <IndexedTuple <string> >(br)
                                .FromIndexed()
                                .ToList();

            character.Trophies = ComplexSerializer
                                 .ReadCollection <IndexedTuple <string> >(br)
                                 .FromIndexed()
                                 .ToList();

            character.KnownBiomes = ComplexSerializer
                                    .ReadCollection <IndexedTuple <int> >(br)
                                    .Select(t => (Biome)t.Item1)
                                    .ToList();

            character.KnownTexts = ComplexSerializer
                                   .ReadCollection <IndexedTuple <string, string> >(br)
                                   .FromIndexed()
                                   .ToList();

            character.Model = ComplexSerializer.Read <Look>(br);

            character.Food = ComplexSerializer
                             .ReadCollection <Food>(br)
                             .ToList();

            character.SkillVersion = br.ReadInt32();
            character.Skills       = ComplexSerializer
                                     .ReadCollection <Skill>(br)
                                     .ToList();
        }