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); }
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(); }
/// <summary> /// Deserilaize the world for the contexted binary reader /// </summary> /// <param name="reader">The binary reader to read from</param> /// <returns>The deserialized world</returns> public override World Read(BinaryReader reader) { return(ComplexSerializer.Read <World>(reader)); }