FSO.Files.Formats.IFF.Chunks.DGRPSprite.Read C# (CSharp) Method

Read() public method

Reads a DGRPSprite from a stream.
public Read ( uint version, IoBuffer io ) : void
version uint
io FSO.Files.Utils.IoBuffer
return void
        public void Read(uint version, IoBuffer io)
        {
            if (version < 20003)
            {
                //Unknown ignored "Type" field
                var type = io.ReadUInt16();
                SpriteID = io.ReadUInt16();
                SpriteFrameIndex = io.ReadUInt16();

                var flagsRaw = io.ReadUInt16();
                Flags = (DGRPSpriteFlags)flagsRaw;

                SpriteOffset.X = io.ReadInt16();
                SpriteOffset.Y = io.ReadInt16();

                if (version == 20001)
                {
                    ObjectOffset.Z = io.ReadFloat();
                }
            }
            else
            {
                SpriteID = io.ReadUInt32();
                SpriteFrameIndex = io.ReadUInt32();
                SpriteOffset.X = io.ReadInt32();
                SpriteOffset.Y = io.ReadInt32();
                ObjectOffset.Z = io.ReadFloat();
                Flags = (DGRPSpriteFlags)io.ReadUInt32();
                if (version == 20004)
                {
                    ObjectOffset.X = io.ReadFloat();
                    ObjectOffset.Y = io.ReadFloat();
                }
            }
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Reads a DGRPImage from a stream.
        /// </summary>
        /// <param name="iff">An Iff instance.</param>
        /// <param name="stream">A Stream object holding a DGRPImage.</param>
        public void Read(uint version, IoBuffer io)
        {
            uint spriteCount = 0;

            if (version < 20003)
            {
                spriteCount = io.ReadUInt16();
                Direction   = io.ReadByte();
                Zoom        = io.ReadByte();
            }
            else
            {
                Direction   = io.ReadUInt32();
                Zoom        = io.ReadUInt32();
                spriteCount = io.ReadUInt32();
            }

            this.Sprites = new DGRPSprite[spriteCount];
            for (var i = 0; i < spriteCount; i++)
            {
                var sprite = new DGRPSprite(Parent);
                sprite.Read(version, io);
                this.Sprites[i] = sprite;
            }
        }
All Usage Examples Of FSO.Files.Formats.IFF.Chunks.DGRPSprite::Read