Ejemplo n.º 1
0
        public override void Write(BinaryWriter writer, Character input)
        {
            ComplexSerializer.Write(writer, input.Statistics);
            foreach (var(_, world) in input.WorldData)
            {
                world.MapData = WriteMapData(world);
            }

            ComplexSerializer.WriteCollection(writer, input.WorldData.Values);
            ComplexSerializer.Write(writer, input);
            writer.Write(true);

            var data = WritePlayerData(input);

            TypeSerializer.WriteBytes(writer, data);
        }
Ejemplo n.º 2
0
        public byte[] WritePlayerData(Character character)
        {
            using var ms = new MemoryStream();
            using var bw = new BinaryWriter(ms);

            ComplexSerializer.Write(bw, character.PlayerData);
            ComplexSerializer.WriteCollection(bw, character.Inventory);
            ComplexSerializer.WriteCollection(bw, character.KnownRecipes.ToIndexed());
            ComplexSerializer.WriteCollection(bw, character.KnownStations.ToIndexed());
            ComplexSerializer.WriteCollection(bw, character.KnownMaterials.ToIndexed());
            ComplexSerializer.WriteCollection(bw, character.KnownTutorials.ToIndexed());
            ComplexSerializer.WriteCollection(bw, character.Uniques.ToIndexed());
            ComplexSerializer.WriteCollection(bw, character.Trophies.ToIndexed());
            ComplexSerializer.WriteCollection(bw, character.KnownBiomes.Select(t => (int)t).ToIndexed());
            ComplexSerializer.WriteCollection(bw, character.KnownTexts.ToIndexed());

            ComplexSerializer.Write(bw, character.Model);
            ComplexSerializer.WriteCollection(bw, character.Food);

            bw.Write(character.SkillVersion);
            ComplexSerializer.WriteCollection(bw, character.Skills);

            return(ms.ToArray());
        }
 /// <summary>
 /// Writes the given world to the contextual binary writer
 /// </summary>
 /// <param name="writer">The writer to serialize to</param>
 /// <param name="world">The world to serialize</param>
 public override void Write(BinaryWriter writer, World world)
 {
     ComplexSerializer.Write(writer, world);
 }