当前位置: 首页>>代码示例>>C#>>正文


C# BitReader类代码示例

本文整理汇总了C#中BitReader的典型用法代码示例。如果您正苦于以下问题:C# BitReader类的具体用法?C# BitReader怎么用?C# BitReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BitReader类属于命名空间,在下文中一共展示了BitReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deserialize

 public static ClientLoadoutOnlineThing Deserialize(BitReader br)
 {
     var clot = new ClientLoadoutOnlineThing(); // ha, "clot"
     clot.Unknown1 = br.ReadUInt32();
     clot.Unknown2 = br.ReadUInt32Max(MAX_UNKNOWN2);
     return clot;
 }
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:7,代码来源:ClientLoadoutOnlineThing.cs

示例2: Deserialize

        public static Reservation Deserialize(UInt32 versionMajor, UInt32 versionMinor, BitReader br)
        {
            var r = new Reservation();

            r.Unknown1 = br.ReadUInt32FromBits(3);

            r.PlayerId = UniqueId.Deserialize(br);

            if (r.PlayerId.Type != UniqueId.UniqueIdType.Unknown)
            {
                r.PlayerName = br.ReadString();
            }

            if (versionMajor < 868 || versionMinor < 12)
            {
                r.Unknown2 = br.ReadBitsAsBytes(2)[0];
            }
            else
            {
                r.Unknown2 = br.ReadByte();
            }
            /*
                ReservationStatus_None,
            ReservationStatus_Reserved,
            ReservationStatus_Joining,
            ReservationStatus_InGame,
            ReservationStatus_MAX
             */

            return r;
        }
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:31,代码来源:Reservation.cs

示例3: Deserialize

 public static ActiveActor Deserialize(BitReader br)
 {
     var aa = new ActiveActor();
     aa.Active = br.ReadBit();
     aa.ActorId = br.ReadUInt32();
     return aa;
 }
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:7,代码来源:ActiveActor.cs

示例4: Deserialize

 public static ClientLoadouts Deserialize(BitReader br)
 {
     var clo = new ClientLoadouts();
     clo.Loadout1 = ClientLoadout.Deserialize(br);
     clo.Loadout2 = ClientLoadout.Deserialize(br);
     return clo;
 }
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:7,代码来源:ClientLoadouts.cs

示例5: Load

        public static void Load(string fileName)
        {
            if (MapList.Count > 0) return;
            using (Stream s = File.OpenRead(fileName))
            {
                using (BitReader read = new BitReader(s))
                {

                    int count = read.ReadInt();
                    for (int i = 0; i < count; i++)
                    {
                        read.Seek(4 + i * 672);
                        MapData map = new MapData();
                        map.MapID = read.ReadInt();

                        map.MapNumber = read.ReadInt();
                        read.Skip(4);
                        map.Name = read.ReadZString(Encoding.ASCII);
                        read.Skip(672 - (int)(336 + (read.InnerStream.BaseStream.Position - (672 * i)) - 4));

                        map.DisplayName = read.ReadZString(Encoding.Unicode);

                        MapList.Add(map.MapID, map);
                    }
                }
            }
            Console.WriteLine("[MapDB] Loaded {0} maps.", MapList.Count);
        }
开发者ID:Kise-Kun,项目名称:Digital-World,代码行数:28,代码来源:MapDB.cs

示例6: Encode

        public static byte[] Encode(byte[] data, int bitsInterval)
        {
            byte[] reverseBytes = Convert.ReverseBitsInBytes(data);

            using (var s = new MemoryStream(reverseBytes))
            using (var reader = new BitReader(s))
            {
                using (var encoded = new MemoryStream())
                using (var writer = new BitWriter(encoded))
                {
                    int counter = 0;
                    while (reader.CanRead)
                    {
                        byte bit = reader.ReadBits(1);
                        writer.WriteBit(bit);
                        counter = (bit == 1) ? counter + 1 : 0;
                        if (counter == bitsInterval)
                        {
                            writer.WriteBit(0);
                            counter = 0;
                        }
                    }

                    writer.FlushBits();
                    return Convert.ReverseBitsInBytes(encoded.ToArray());
                }
            }
        }
开发者ID:anddudek,项目名称:anjlab.fx,代码行数:28,代码来源:Ax25.cs

示例7: ApplyToFrame

 public override object ApplyToFrame( VorbisCodec codec, BitReader reader, object args )
 {
     step2Flag[0] = true; step2Flag[1] = true;
     finalY[0] = yList[0]; finalY[1] = yList[1];
     SynthesiseAmplitudeValues();
     return SynthesiseCurve( (int)args );
 }
开发者ID:UnknownShadow200,项目名称:SharpWave,代码行数:7,代码来源:Floor.cs

示例8: Deserialize

        public static ClientLoadoutOnline Deserialize(BitReader br)
        {
            var clo = new ClientLoadoutOnline();
            clo.ThingLists = new List<List<ClientLoadoutOnlineThing>>();

            var listCount = br.ReadByte();
            for (int i = 0; i < listCount; ++i)
            {
                var thingList = new List<ClientLoadoutOnlineThing>();

                var thingCount = br.ReadByte();
                for (int j = 0; j < thingCount; ++j)
                {
                    thingList.Add(ClientLoadoutOnlineThing.Deserialize(br));

                    if ( i >= 21 )
                    {
                        thingList.Add(ClientLoadoutOnlineThing.Deserialize(br));
                    }
                }

                clo.ThingLists.Add(thingList);
            }

            return clo;
        }
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:26,代码来源:ClientLoadoutOnline.cs

示例9: PlayerJoinEvent

        public PlayerJoinEvent(BitReader bitReader, Replay replay, int playerIndex)
        {
            this.EventType = GameEventType.Inactive;

            // This should probably be a series of {shl; or} on .Read(1)
            // to make it version-independent
            if (replay.ReplayBuild < 22612)
            {
                this.JoinFlags = (int)bitReader.Read(4);
            }
            else
            {
                this.JoinFlags = (int)bitReader.Read(12); // unknown
            }

            // Initialize player if not exists (true for observers)
            Player player = replay.GetPlayerById(playerIndex);
            if (player == null)
            {
                var p = new Player { PlayerType = PlayerType.Spectator };
                replay.ClientList[playerIndex] = player = p;
            }

            // Initialize wireframe
            player.Wireframe = new List<Unit>();
            player.WireframeSubgroup = 0;

            // Initialize control groups
            player.Hotkeys = new List<Unit>[10];
        }
开发者ID:kensniper,项目名称:sc2replay-csharp,代码行数:30,代码来源:PlayerJoinEvent.cs

示例10: SendResourcesEvent

        public SendResourcesEvent(BitReader bitReader, Replay replay)
        {
            this.EventType = GameEventType.Other;

            var playerId = (int)bitReader.Read(4);
            Target = replay.GetPlayerById(playerId);

            var someFlags = (int)bitReader.Read(3);

            if (someFlags-- > 0) // 4
            {
                MineralsSent = ReadSignedAmount(bitReader.Read(32));
            }
            if (someFlags-- > 0) // 3
            {
                VespeneSent = ReadSignedAmount(bitReader.Read(32));
            }
            if (someFlags-- > 0) // 2
            {
                TerrazineSent = ReadSignedAmount(bitReader.Read(32));
            }
            if (someFlags-- > 0) // 1
            {
                CustomSent = ReadSignedAmount(bitReader.Read(32));
            }
        }
开发者ID:kensniper,项目名称:sc2replay-csharp,代码行数:26,代码来源:SendResourcesEvent.cs

示例11: ReadSetupData

        public override void ReadSetupData( VorbisCodec codec, BitReader reader )
        {
            int residueBegin = reader.ReadBits( 24 );
            int residueEnd = reader.ReadBits( 24 );
            int partitionSize = reader.ReadBits( 24 ) + 1;
            int classifications = reader.ReadBits( 6 ) + 1;
            int classbook = reader.ReadBits( 8 );

            byte[] residueCascade = new byte[classifications];
            for( int i = 0; i < residueCascade.Length; i++ ) {
                int highBits = 0;
                int lowBits = reader.ReadBits( 3 );
                if( reader.ReadBit() == 1 )
                    highBits = reader.ReadBits( 5 );
                residueCascade[i] = (byte)( lowBits | ( highBits << 3 ) );
            }

            byte[][] bookNumbers = new byte[classifications][];
            for( int i = 0; i < bookNumbers.Length; i++ ) {
                byte[] nums = new byte[8];
                int cascade = residueCascade[i];
                for( int j = 0; j < nums.Length; j++ ) {
                    if( ( cascade & ( 1 << j ) ) != 0 ) {
                        nums[j] = (byte)reader.ReadBits( 8 );
                    }
                }
                bookNumbers[i] = nums;
            }
        }
开发者ID:UnknownShadow200,项目名称:SharpWave,代码行数:29,代码来源:Residue.cs

示例12: CameraEvent

        public CameraEvent(BitReader bitReader, Replay replay)
        {
            TargetX = CFixedToDouble(bitReader.Read(16));
            TargetY = CFixedToDouble(bitReader.Read(16));

            HasDistance = bitReader.Read(1) != 0;
            if (HasDistance)
            {
                Distance = CFixedToDouble(bitReader.Read(16));
            }

            HasPitch = bitReader.Read(1) != 0;
            if (HasPitch)
            {
                Pitch = RotationAmountToDegrees(bitReader.Read(16));
            }

            HasYaw = bitReader.Read(1) != 0;
            if (HasYaw)
            {
                Yaw = RotationAmountToDegrees(bitReader.Read(16));
            }

            HasHeightOffset = bitReader.Read(1) != 0;
            if (HasHeightOffset)
            {
                // Debug since we're unsure
                HeightOffset = CFixedToDouble(bitReader.Read(16));
            }

            this.EventType = GameEventType.Other;
        }
开发者ID:kensniper,项目名称:sc2replay-csharp,代码行数:32,代码来源:CameraEvent.cs

示例13: Load

        public static void Load(string fName)
        {
            using (Stream s = File.OpenRead(fName))
            {
                using (BitReader read = new BitReader(s))
                {
                    int c = read.ReadInt();
                    for (int i = 0; i < c; i++)
                    {
                        TDBTactic t = new TDBTactic();
                        t.ItemId = read.ReadInt();
                        t.Species = read.ReadInt();
                        t.uInt1 = read.ReadInt();
                        t.Data = read.ReadInt();
                        t.uInt2 = read.ReadInt();
                        t.uInt3 = read.ReadInt();
                        t.uInt4 = read.ReadInt();

                        Tactics.Add(t.ItemId, t);
                    }

                    //More data at the end. Digimon names and descriptions.
                }
            }
            Console.WriteLine("[TacticsDB] Loaded {0} entries.", Tactics.Count);
        }
开发者ID:Comfy-Mittens,项目名称:Digital-World,代码行数:26,代码来源:TacticsDB.cs

示例14: Decode

        public static byte[] Decode(byte[] data, int from, int to, int bitsInterval)
        {
            var copiedData = new byte[to - from + 1];
            Array.Copy(data, from, copiedData, 0, copiedData.Length);

            byte[] reverseBytes = Convert.ReverseBitsInBytes(copiedData);

            using (var s = new MemoryStream(reverseBytes))
            using (var reader = new BitReader(s))
            {
                using (var decoded = new MemoryStream())
                using (var writer = new BitWriter(decoded))
                {
                    int counter = 0;
                    while (reader.CanRead)
                    {
                        byte bit = reader.ReadBits(1);
                        writer.WriteBit(bit);
                        counter = (bit == 1) ? counter + 1 : 0;
                        if (counter == bitsInterval)
                        {
                            reader.ReadBits(1); // skip next 0 bit
                            counter = 0;
                        }
                    }

                    // !! do not flush last bits
                    return Convert.ReverseBitsInBytes(decoded.ToArray());
                }
            }
        }
开发者ID:anddudek,项目名称:anjlab.fx,代码行数:31,代码来源:Ax25.cs

示例15: SetData

 public void SetData(ref BitReader Src, int CountBits)
 {
     Num = CountBits;
     Pos = 0;
     Src.Data = null;
     Src.Data = new byte[((CountBits + 7) >> 3)];
     Src.SerializeBits(Src.Data, CountBits);
 }
开发者ID:fiki574,项目名称:rAPB,代码行数:8,代码来源:BitReader.cs


注:本文中的BitReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。