Example #1
0
		public WavLoader(Stream s)
		{
			while (s.Position < s.Length)
			{
				if ((s.Position & 1) == 1)
					s.ReadByte(); // Alignment

				var type = s.ReadASCII(4);
				switch (type)
				{
					case "RIFF":
						FileSize = s.ReadInt32();
						Format = s.ReadASCII(4);
						if (Format != "WAVE")
							throw new NotSupportedException("Not a canonical WAVE file.");
						break;
					case "fmt ":
						FmtChunkSize = s.ReadInt32();
						AudioFormat = s.ReadInt16();
						Type = (WaveType)AudioFormat;
						if (Type != WaveType.Pcm && Type != WaveType.ImaAdpcm)
							throw new NotSupportedException("Compression type is not supported.");
						Channels = s.ReadInt16();
						SampleRate = s.ReadInt32();
						ByteRate = s.ReadInt32();
						BlockAlign = s.ReadInt16();
						BitsPerSample = s.ReadInt16();

						s.ReadBytes(FmtChunkSize - 16);
						break;
					case "fact":
						{
							var chunkSize = s.ReadInt32();
							UncompressedSize = s.ReadInt32();
							s.ReadBytes(chunkSize - 4);
						}

						break;
					case "data":
						DataSize = s.ReadInt32();
						RawOutput = s.ReadBytes(DataSize);
						break;
					default:
						// Ignore unknown chunks
						{
							var chunkSize = s.ReadInt32();
							s.ReadBytes(chunkSize);
						}

						break;
				}
			}

			if (Type == WaveType.ImaAdpcm)
			{
				RawOutput = DecodeImaAdpcmData();
				BitsPerSample = 16;
			}
		}
Example #2
0
        public static float WaveLength(Stream s)
        {
            s.Position = 12;
            var fmt = s.ReadASCII(4);

            if (fmt != "fmt ")
                return 0;

            s.Position = 22;
            var channels = s.ReadInt16();
            var sampleRate = s.ReadInt32();

            s.Position = 34;
            var bitsPerSample = s.ReadInt16();
            var length = s.Length * 8;

            return length / (channels * sampleRate * bitsPerSample);
        }
Example #3
0
        public WavLoader(Stream s)
        {
            while (s.Position < s.Length)
            {
                if ((s.Position & 1) == 1)
                    s.ReadByte(); // Alignment

                var type = s.ReadASCII(4);
                switch (type)
                {
                    case "RIFF":
                        FileSize = s.ReadInt32();
                        Format = s.ReadASCII(4);
                        if (Format != "WAVE")
                            throw new NotSupportedException("Not a canonical WAVE file.");
                        break;
                    case "fmt ":
                        FmtChunkSize = s.ReadInt32();
                        if (FmtChunkSize != 16)
                            throw new NotSupportedException("{0} fmt chunk size is not a supported encoding scheme.".F(FmtChunkSize));
                        AudioFormat = s.ReadInt16();
                        if (AudioFormat != 1)
                            throw new NotSupportedException("Non-PCM compression is not supported.");
                        Channels = s.ReadInt16();
                        SampleRate = s.ReadInt32();
                        ByteRate = s.ReadInt32();
                        BlockAlign = s.ReadInt16();
                        BitsPerSample = s.ReadInt16();
                        break;
                    case "data":
                        DataSize = s.ReadInt32();
                        RawOutput = s.ReadBytes(DataSize);
                        break;
                    default:
                        // Ignore unknown chunks
                        var chunkSize = s.ReadInt32();
                        s.ReadBytes(chunkSize);
                        break;
                }
            }
        }
Example #4
0
        public void Unpack(Stream stream)
        {
            var flags = (TileFlags) stream.ReadInt8();

            Active = flags.HasFlag(TileFlags.Active);
            if (Active)
            {
                Type = stream.ReadInt8();
                if (FrameImportant)
                {
                    FrameX = stream.ReadInt16();
                    FrameY = stream.ReadInt16();
                }
            }

            if (flags.HasFlag(TileFlags.Wall))
            {
                Wall = stream.ReadInt8();
            }

            if (flags.HasFlag(TileFlags.Liquid))
            {
                Liquid = stream.ReadInt8();
                Lava = stream.ReadBoolean();
            }

            if (flags.HasFlag(TileFlags.Wire))
                Wire = true;
        }
        private bool ResumeTicket(IDigest hash, Stream stream, byte[] additionalChallenge)
        {
            // Successful Resume Session (If mode = 1)
            //  C => S
            //  byte    ChallengeLength
            //  byte[]  A = Challenge
            //  int16   TicketLength
            //  byte[]  Ticket
            //  C <= S
            //  bool    IsSuccess = true
            //  byte    HashMethod
            //  byte    ChallengeLength
            //  byte[]  B = Challenge
            //  C => S  
            //  byte[]  M1 = H(A | B | SessionKey)
            //  Bool    Success (if false, done)
            //  C <= S
            //  byte[]  M2 = H(B | A | SessionKey)

            // Failed Resume Session
            //  C => S
            //  byte    ChallengeLength
            //  byte[]  A = Challenge
            //  int16   TicketLength
            //  byte[]  Ticket
            //  C <= S
            //  bool    IsSuccess = false
            //  Goto Authenticate Code

            byte[] a = stream.ReadBytes(stream.ReadNextByte());
            int ticketLength = stream.ReadInt16();
            if (ticketLength < 0 || ticketLength > 10000)
                return false;

            byte[] ticket = stream.ReadBytes(ticketLength);

            if (TryLoadTicket(ticket, m_user, out SessionSecret))
            {
                stream.Write(true);
                stream.WriteByte((byte)SrpHashMethod);
                byte[] b = SaltGenerator.Create(16);
                stream.WriteByte(16);
                stream.Write(b);
                stream.Flush();

                byte[] clientProofCheck = hash.ComputeHash(a, b, SessionSecret, additionalChallenge);
                byte[] serverProof = hash.ComputeHash(b, a, SessionSecret, additionalChallenge);
                byte[] clientProof = stream.ReadBytes(hash.GetDigestSize());

                if (clientProof.SecureEquals(clientProofCheck))
                {
                    stream.Write(true);
                    stream.Write(serverProof);
                    stream.Flush();
                    return true;
                }
                stream.Write(false);
                return false;
            }
            stream.Write(false);
            return StandardAuthentication(hash, stream, additionalChallenge);
        }
        /// <summary>
        /// ストリームからタグ情報を読み込みます。
        /// オブジェクトのデータ構造は以下のようになります。
        ///
        ///   1.タグのサイズ ( 2byte )  x タグ数
        ///   2.タグの内容 ( サイズ分 ) x タグ数
        ///
        /// よって、はじめにサイズを読み、次にその分だけ値を取得してゆきます。
        /// </summary>
        /// <param name="src">オブジェクト情報を読み取るストリーム。位置はオブジェクトのボディ先頭 ( サイズ情報の直後 ) に設定します。</param>
        private void Load( Stream src )
        {
            var length = new int[ RequiredTagCount ] { src.ReadInt16(), src.ReadInt16(), src.ReadInt16(), src.ReadInt16(), src.ReadInt16() };
            var names = RequiredTagNames;

            for( var i = 0; i < ContentDescriptionObject.RequiredTagCount; ++i )
            {
                this._tags.Add( names[ i ], new ObjectTagValue( ObjectTagValueType.String, src.Position, length[ i ] ) );
                src.Seek( length[ i ], SeekOrigin.Current );
            }
        }
Example #7
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 0)
            {
                OwnerIdentifier = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                if (bytesLeft >= 4)
                {
                    PreviewStart = stream.ReadInt16(ref bytesLeft);
                    PreviewLength = stream.ReadInt16(ref bytesLeft);
                    if (bytesLeft > 0)
                    {
                        EncryptionInfo = stream.Read(bytesLeft);
                        bytesLeft = 0;
                    }
                    else
                    {
                        // Incomplete frame
                        EncryptionInfo = null;
                    }
                }
                else
                {
                    // Incomplete frame
                    PreviewStart = 0;
                    PreviewLength = 0;
                    EncryptionInfo = null;
                }
            }
            else
            {
                // Incomplete frame
                OwnerIdentifier = null;
                PreviewStart = 0;
                PreviewLength = 0;
                EncryptionInfo = null;
            }

            // Seek to end of frame
            if (bytesLeft != 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
Example #8
0
 private static MidHeader ReadHeader(Stream s)
 {
     if (!s.Read(4).SequenceEqual(new byte[] { 0x4D, 0x54, 0x68, 0x64 }))
     {
         throw new InvalidDataException("不是有效的mid文件");
     }
     s.ReadInt32();
     var header = new MidHeader();
     header.FormatType = s.ReadInt16();
     header.TrackCount = s.ReadInt16();
     header.TicksPerBeat = s.ReadInt16();
     if ((header.TicksPerBeat & 0x8000) != 0)
     {
         throw new InvalidDataException("不支持SMTPE时间格式");
     }
     return header;
 }
Example #9
0
 public static object Read(Stream stream)
 {
     return stream.ReadInt16();
 }
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            // RVAD/RVA2
            /*Double original = -65534;
            Double newVal = Math.Log10(1 + original/65535.0)*20.0*512.0;
            Double original2 = Math.Pow(10, newVal/(20.0*512.0));
            original2 = original2 - 1;
            original2 *= 65535.0;*/

            /*Double original = 10000;
            Double newVal = Math.Log10(1 + original / 65535.0);
            Double original2 = Math.Pow(10, newVal);
            original2 = original2 - 1;
            original2 *= 65535.0;*/

            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;
            if (bytesLeft > 0)
            {
                // todo: there needs to be some kind of a test to see if this is RVAD/RVA2 format, too
                // much varying implementation in 2.3 and 2.4

                bool isRVA2 = (_frameHeader.TagVersion == ID3v2TagVersion.ID3v24);

                if (isRVA2)
                {
                    // sometimes "identification" is completely ommitted... grr
                    Identification = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                    while (bytesLeft >= 3)
                    {
                        // TODO: Implementation not complete
                        byte channelType = stream.Read1(ref bytesLeft);
                        //if (channelType == 16) break; // Invalid, probably stored as an ID3v2.3 RVAD frame
                        // TODO: some kind of switch.. maybe a new internal enum
                        short volumeAdjustment = stream.ReadInt16(ref bytesLeft);
                        if (bytesLeft > 0)
                        {
                            // sometimes represented as BITS representing peak.. seriously.
                            byte bytesRepresentingPeak = stream.Read1(ref bytesLeft);
                            if (bytesRepresentingPeak == 0) break;
                            if (bytesLeft >= bytesRepresentingPeak)
                            {
                                // TODO: Finish implementation
                                byte[] peakVolume = stream.Read(bytesRepresentingPeak);
                                bytesLeft -= peakVolume.Length;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    if (bytesLeft > 0)
                    {
                        //Trace.WriteLine("Invalid RVA2 frame");
                        //stream.Seek(bytesLeft, SeekOrigin.Current);
                        //bytesLeft = 0;
                        // Try to read it like an ID3v2.3 RVAD frame
                        stream.Seek(bytesLeft - _frameHeader.FrameSizeExcludingAdditions, SeekOrigin.Current);
                        bytesLeft = _frameHeader.FrameSizeExcludingAdditions;
                        isRVA2 = false;
                    }
                    else
                    {
                        // TODO
                        //MessageBox.Show("valid RVA2 frame, omg!");
                    }
                }

                // ID3v2.2, ID3v2.3, or mal-formed ID3v2.4
                if (isRVA2 == false)
                {
                    byte incrementDecrement = stream.Read1(ref bytesLeft);
                    if (bytesLeft > 0)
                    {
                        byte bitsUsedForVolumeDescription = stream.Read1(ref bytesLeft);
                        int bytesUsedForVolumeDescription = bitsUsedForVolumeDescription / 8;

                        // TODO: (may be useful for testing which implementation)
                        // if bits used for volume description is > 64, don't bother

                        // Relative volume change, right
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontRightAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 0) ? 1 : -1);
                        }
                        // Relative volume change, left
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontLeftAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 1) ? 1 : -1);
                        }
                        // Peak volume right
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontRightPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                        // Peak volume left
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontLeftPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                        // Relative volume change, right back
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            BackRightAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 2) ? 1 : -1);
                        }
                        // Relative volume change, left back
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            BackLeftAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 3) ? 1 : -1);
                        }
                        // Peak volume right back
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            BackRightPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                        // Peak volume left back
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            BackLeftPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                        // Relative volume change, center
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontCenterAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 4) ? 1 : -1);
                        }
                        // Peak volume center
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontCenterPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                        // Relative volume change, bass
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            SubwooferAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 5) ? 1 : -1);
                        }
                        // Peak volume bass
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            SubwooferPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                    }
                }

                // Skip past the rest of the frame
                if (bytesLeft > 0)
                {
                    Trace.WriteLine("Invalid RVA2/RVAD/RVA frame");
                    stream.Seek(bytesLeft, SeekOrigin.Current);
                    //bytesLeft = 0;
                }
            }
        }
        // TODO: Still probably needs some more work to read the pixel array properly in case of non 4-byte aligned rows
        private unsafe static void GetBmpDataFromStream(Stream dataStream, byte* dataPointer, uint imageSizeInBytes)
        {
            // Start reading from the position of the pixel array offset information in the bitmap header
            const int startOffset = 10;
            dataStream.Seek(startOffset, SeekOrigin.Begin);

            int pixelArrayOffset = dataStream.ReadInt32();

            // Read in some data from the dib header
            int dibHeaderSize = dataStream.ReadInt32();
            int bitmapWidth = dataStream.ReadInt32();
            int bitmapHeight = dataStream.ReadInt32();
            int colorPlaneCount = dataStream.ReadInt16();
            int bitsPerPixel = dataStream.ReadInt16();

            Debug.Assert(colorPlaneCount == 1);
            Debug.Assert(imageSizeInBytes == bitmapWidth*bitmapHeight*(bitsPerPixel>>3));

            // Everything ok, time to read the actual pixel data
            dataStream.Seek(pixelArrayOffset, SeekOrigin.Begin);

            //dataStream.Read(dataPointer, 0, (int)imageSizeInBytes);
            dataStream.ReadNoAlloc(dataPointer, 0, (int)imageSizeInBytes);
        }
Example #12
0
		public void Unpack(Stream stream)
		{
			var flags = (BitsByte) stream.ReadInt8();
			var flags2 = (BitsByte)stream.ReadInt8();

			Wire2 = flags2[0];
			Wire3 = flags2[1];
			Slope = flags2[4];
			Slope2 = flags2[5];
			Slope3 = flags2[6];

			if (flags2[2])
			{
				TileColor = stream.ReadInt8();
			}

			if (flags2[3])
			{
				WallColor = stream.ReadInt8();
			}

			Active = flags[0];
			if (Active)
			{
				Type = stream.ReadUInt16();
				if (FrameImportant)
				{
					FrameX = stream.ReadInt16();
					FrameY = stream.ReadInt16();
				}
			}

			if (flags[2])
			{
				Wall = stream.ReadInt8();
			}

			if (flags[3])
			{
				Liquid = stream.ReadInt8();
				LiquidType = stream.ReadInt8();
			}

			if (flags[4])
				Wire = true;

			if (flags[5])
				IsHalf = true;
			
			if (flags[6])
				IsActuator = true;

			if (flags[7])
			{
				Inactive = true;
				Active = false;
			}
		}
        public IEnumerable<Record> Read(Stream s)
        {
            if (Encoding.ASCII.GetString(s.ReadBytes(7)) != "ARCH000")
                throw new NotSupportedException("Not a boir file");
            var compressed = s.ReadByte();
            var recordStart = s.ReadInt32();
            var recordCount = s.ReadInt16();

            s.Position = recordStart;
            for (int i = 0; i < recordCount; i++)
            {
                Record rec = null;
                switch ((FileType)compressed)
                {
                    case FileType.Compressed:
                        rec = (Record)new CompressedRecord();
                        break;
                    case FileType.Encrypted:
                        rec = new EncryptedRecord();
                        break;
                    case FileType.Encrypted2:
                        rec = new MiniZCompressedRecord();
                        break;
                }
                rec.Read(s);

                yield return rec;
            }
        }
        private bool Authenticate(Stream stream, byte[] additionalChallenge)
        {
            HashMethod passwordHashMethod = (HashMethod)stream.ReadNextByte();
            byte[] salt = stream.ReadBytes(stream.ReadNextByte());
            int iterations = stream.ReadInt32();

            SetHashMethod((HashMethod)stream.ReadNextByte());
            SetSrpStrength((SrpStrength)stream.ReadInt32());

            m_credentials.TryUpdate(passwordHashMethod, salt, iterations);

            BigInteger pubA = m_client.GenerateClientCredentials(m_hash, salt, m_credentials.UsernameBytes, m_credentials.SaltedPassword);
            byte[] pubABytes = pubA.ToPaddedArray(m_srpByteLength);

            stream.Write(pubABytes);
            stream.Flush();

            //Read from Server: B
            byte[] pubBBytes = stream.ReadBytes(m_srpByteLength);
            BigInteger pubB = new BigInteger(1, pubBBytes);

            //Calculate Session Key
            BigInteger S = m_client.CalculateSecret(m_hash, pubB);
            byte[] SBytes = S.ToPaddedArray(m_srpByteLength);

            byte[] clientProof = m_hash.ComputeHash(pubABytes, pubBBytes, SBytes, additionalChallenge);
            stream.Write(clientProof);
            stream.Flush();

            byte[] serverProof = m_hash.ComputeHash(pubBBytes, pubABytes, SBytes, additionalChallenge);

            if (stream.ReadBoolean())
            {
                byte[] serverProofCheck = stream.ReadBytes(m_hash.GetDigestSize());
                int ticketLength = stream.ReadInt16();
                if (ticketLength < 0 || ticketLength > 10000)
                    return false;

                if (serverProofCheck.SecureEquals(serverProof))
                {
                    m_resumeTicket = stream.ReadBytes(ticketLength);
                    m_sessionSecret = m_hash.ComputeHash(pubABytes, SBytes, pubBBytes).Combine(m_hash.ComputeHash(pubBBytes, SBytes, pubABytes));
                    return true;
                }
                return false;
            }
            return false;
        }
Example #15
0
        public bool LoadSound(Stream s)
        {
            var type = s.ReadASCII(4);
            if (type != "RIFF")
                return false;

            FileSize = s.ReadInt32();
            Format = s.ReadASCII(4);
            if (Format != "WAVE")
                return false;
            while (s.Position < s.Length)
            {
                if ((s.Position & 1) == 1)
                    s.ReadByte(); // Alignment

                type = s.ReadASCII(4);
                switch (type)
                {
                    case "fmt ":
                        FmtChunkSize = s.ReadInt32();
                        AudioFormat = s.ReadInt16();
                        Type = (WaveType)AudioFormat;

                        if (!Enum.IsDefined(typeof(WaveType), Type))
                            throw new NotSupportedException("Compression type {0} is not supported.".F(AudioFormat));

                        Channels = s.ReadInt16();
                        SampleRate = s.ReadInt32();
                        ByteRate = s.ReadInt32();
                        BlockAlign = s.ReadInt16();
                        BitsPerSample = s.ReadInt16();

                        s.ReadBytes(FmtChunkSize - 16);
                        break;
                    case "fact":
                        var chunkSize = s.ReadInt32();
                        UncompressedSize = s.ReadInt32();
                        s.ReadBytes(chunkSize - 4);
                        break;
                    case "data":
                        DataSize = s.ReadInt32();
                        RawOutput = s.ReadBytes(DataSize);
                        break;
                    default:
                        var unknownChunkSize = s.ReadInt32();
                        s.ReadBytes(unknownChunkSize);
                        break;
                }
            }

            if (Type == WaveType.ImaAdpcm)
            {
                RawOutput = DecodeImaAdpcmData();
                BitsPerSample = 16;
            }

            return true;
        }
Example #16
0
        public void Unpack(Stream stream)
        {
            var flags = (TileFlags) stream.ReadInt8();
            var flags2 = (TileFlags2)stream.ReadInt8();

            Wire2 = flags2.HasFlag(TileFlags2.Wire2);
            Wire3 = flags2.HasFlag(TileFlags2.Wire3);
            Slope = flags2.HasFlag(TileFlags2.Slope);
            Slope2 = flags2.HasFlag(TileFlags2.Slope2);

            if (flags2.HasFlag(TileFlags2.Color))
            {
                TileColor = stream.ReadInt8();
            }

            if (flags2.HasFlag(TileFlags2.WallColor))
            {
                WallColor = stream.ReadInt8();
            }

            Active = flags.HasFlag(TileFlags.Active);
            if (Active)
            {
                Type = stream.ReadInt8();
                if (FrameImportant)
                {
                    FrameX = stream.ReadInt16();
                    FrameY = stream.ReadInt16();
                }
            }

            if (flags.HasFlag(TileFlags.Lighted))
            {
                Lighted = true;
            }

            if (flags.HasFlag(TileFlags.Wall))
            {
                Wall = stream.ReadInt8();
            }

            if (flags.HasFlag(TileFlags.Liquid))
            {
                Liquid = stream.ReadInt8();
                LiquidType = stream.ReadInt8();
            }

            if (flags.HasFlag(TileFlags.Wire))
                Wire = true;

            if (flags.HasFlag(TileFlags.HalfBrick))
                IsHalf = true;

            if (flags.HasFlag(TileFlags.Actuator))
                IsActuator = true;

            if (flags.HasFlag(TileFlags.Inactive))
            {
                Inactive = true;
                Active = false;
            }
        }
Example #17
0
 public void Unpack(Stream stream)
 {
     Field6 = stream.ReadInt8();
     Field8 = stream.ReadInt16();
     Field8 = stream.ReadInt32();
     Field9 = stream.ReadBytes();
     Field10 = stream.ReadString();
 }