Exemplo 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);
        }
Exemplo n.º 2
0
        public static void GameObjectFromStream(Stream stream, GameObject into)
        {
            GameObjectSerializer.Read(stream, into);

            int numSavedComponents = stream.ReadInt();

            for (int i = 0; i < numSavedComponents; i++)
            {
                var type      = TypeSerializer.Read(stream);
                var component = into.GetOrAddComponent(type);
                ComponentFromStream(stream, type, component);
            }
        }
        public override void SetMember(TContainingType obj, [NotNull] IWireStreamReaderStrategy source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            try
            {
                MemberSetter.Setter(obj, (TMemberType)TypeSerializer.Read(source));
            }
            catch (Exception e)
            {
                throw new InvalidOperationException($"Failed to set member {MemberInformation.Name} on Type: {MemberInformation.DeclaringType} for Type: {obj.GetType().Name} Exception: {e.Message}.", e);
            }
        }