/// <summary>
 /// Function to read the animation data from a stream.
 /// </summary>
 /// <param name="stream">The stream containing the animation.</param>
 /// <param name="byteCount">The number of bytes to read from the stream.</param>
 /// <returns>A new <see cref="IGorgonAnimation"/>.</returns>
 protected override IGorgonAnimation OnReadFromStream(Stream stream, int byteCount)
 {
     using (var wrappedStream = new GorgonStreamWrapper(stream, stream.Position, byteCount, false))
     {
         using (var reader = new StreamReader(wrappedStream, Encoding.UTF8, true, 80192, true))
         {
             string jsonString = reader.ReadToEnd();
             return(FromJson(Renderer, jsonString));
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Function to read the sprite data from a stream.
 /// </summary>
 /// <param name="stream">The stream containing the sprite.</param>
 /// <param name="byteCount">The number of bytes to read from the stream.</param>
 /// <param name="overrideTexture">The texture to assign to the sprite instead of the texture associated with the name stored in the file.</param>
 /// <returns>A new <see cref="GorgonPolySprite"/>.</returns>
 protected override GorgonPolySprite OnReadFromStream(Stream stream, int byteCount, GorgonTexture2DView overrideTexture)
 {
     using (var wrappedStream = new GorgonStreamWrapper(stream, stream.Position, byteCount, false))
     {
         using (var reader = new StreamReader(wrappedStream, Encoding.UTF8, true, 80192, true))
         {
             string jsonString = reader.ReadToEnd();
             return(FromJson(Renderer, overrideTexture, jsonString));
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GorgonChunkFile{T}"/> class.
        /// </summary>
        /// <param name="stream">The stream that contains the chunk file to read or write.</param>
        /// <remarks>
        /// The <paramref name="stream"/> passed to this method requires that the <see cref="System.IO.Stream.CanSeek"/> property returns a value of <b>true</b>.
        /// </remarks>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="stream" /> parameter is <b>null</b>.</exception>
        /// <exception cref="ArgumentEmptyException">Thrown when the <paramref name="stream"/> is has its <see cref="System.IO.Stream.CanSeek"/> property set to <b>false</b>.</exception>
        protected GorgonChunkFile(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            if (!stream.CanSeek)
            {
                throw new ArgumentException(Resources.GOR_ERR_STREAM_NOT_SEEKABLE, nameof(stream));
            }

            ChunkList = new GorgonChunkCollection();
            Stream    = new GorgonStreamWrapper(stream);
        }