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


C# BitReader.ReadBit方法代码示例

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


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

示例1: GetGraphicInfo

        public static void GetGraphicInfo(BitReader reader, ref Item item)
        {
            item.has_graphic = reader.ReadBit(); ;
            if (item.has_graphic)
                item.graphic = (byte)reader.Read(3);

            item.has_colour = reader.ReadBit();
            if (item.has_colour)
                item.colour = (UInt16)reader.Read(11);
        }
开发者ID:uvbs,项目名称:OmegaBot,代码行数:10,代码来源:Parser.cs

示例2: Deserialize

        public static ReplicatedDemolish Deserialize(BitReader br)
        {
            var rd = new ReplicatedDemolish();

            rd.Unknown1 = br.ReadBit();
            rd.AttackerActorId = br.ReadUInt32();
            rd.Unknown2 = br.ReadBit();
            rd.VictimActorId = br.ReadUInt32();
            rd.AttackerVelocity = Vector3D.Deserialize(br);
            rd.VictimVelocity = Vector3D.Deserialize(br);

            return rd;
        }
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:13,代码来源:ReplicatedDemolish.cs

示例3: GammaDecode

        public static ulong GammaDecode(BitReader reader)
        {
            int size = 0;

            while (reader.ReadBit() == false)
                size++;

            ulong result = 1;

            for (int i = 0; i < size; i++)
                result = (result << 1) + (reader.ReadBit() ? 1UL : 0UL);

            return result - 1;
        }
开发者ID:svick,项目名称:Arithmetic-coding,代码行数:14,代码来源:Elias.cs

示例4: 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

示例5: 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

示例6: Deserialize

 public static Rotator Deserialize(BitReader br)
 {
     var r = new Rotator();
     if (br.ReadBit())
     {
         r.Pitch = ByteToAxis(br.ReadByte());
     }
     if ( br.ReadBit() )
     {
         r.Yaw = ByteToAxis(br.ReadByte());
     }
     if (br.ReadBit())
     {
         r.Roll = ByteToAxis(br.ReadByte());
     }
     return r;
 }
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:17,代码来源:Rotator.cs

示例7: Deserialize

        public static WeldedInfo Deserialize(BitReader br)
        {
            var wi = new WeldedInfo();
            wi.Active = br.ReadBit();
            wi.ActorId = br.ReadInt32();
            wi.Offset = Vector3D.Deserialize(br);
            wi.Mass = br.ReadFloat();
            wi.Rotation = Rotator.Deserialize(br);

            return wi;
        }
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:11,代码来源:WeldedInfo.cs

示例8: Deserialize

        public static PrivateMatchSettings Deserialize(BitReader br)
        {
            var pms = new PrivateMatchSettings();
            pms.Mutators = br.ReadString().Split(',').ToList();
            pms.Unknown1 = br.ReadUInt32(); // GameNameId? Possibly referencing a string by id
            pms.Unknown2 = br.ReadUInt32(); // Max players?
            pms.GameName = br.ReadString();
            pms.Password = br.ReadString();
            pms.Unknown3 = br.ReadBit(); // Public?

            return pms;
        }
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:12,代码来源:PrivateMatchSettings.cs

示例9: Deserialize

        public static RigidBodyState Deserialize(BitReader br)
        {
            var rbs = new RigidBodyState();
            rbs.Sleeping = br.ReadBit();
            rbs.Position = Vector3D.Deserialize(br);
            rbs.Rotation = Vector3D.DeserializeFixed(br);

            if (!rbs.Sleeping)
            {
                rbs.LinearVelocity = Vector3D.Deserialize(br);
                rbs.AngularVelocity = Vector3D.Deserialize(br);
            }

            return rbs;
        }
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:15,代码来源:RigidBodyState.cs

示例10: ReadPerPacketData

        public override object ReadPerPacketData( VorbisCodec codec, BitReader reader, object args )
        {
            bool emptyThisFrame = reader.ReadBit() == 0;
            if( emptyThisFrame ) return true;

            int offset = 0;
            yList[offset++] = reader.ReadBits( elems01Bits );
            yList[offset++] = reader.ReadBits( elems01Bits );

            for( int i = 0; i < partitions; i++ ) {
                int classNum = partitionClassList[i];
                int cDim = classDimensions[classNum];
                int cBits = classSubclasses[classNum];
                int cSub = (1 << cBits) - 1;
                int cVal = 0;
                if( cBits > 0 ) {
                    int bookNum = classMasterbooks[classNum];
                    Codebook codebook = codec.codebookConfigs[bookNum];
                    cVal = codebook.GetScalarContext( reader );
                }

                for( int j = 0; j < cDim; j++ ) {
                    int book = subclassBooks[classNum][cVal & cSub];
                    cVal = (int)((uint)cVal >> cBits);
                    if( book != 0xFF ) {
                        Codebook codebook = codec.codebookConfigs[book];
                        yList[offset++] = codebook.GetScalarContext( reader );
                    } else {
                        yList[offset++] = 0;
                    }
                }
            }
            return false;
        }
开发者ID:UnknownShadow200,项目名称:SharpWave,代码行数:34,代码来源:Floor.cs

示例11: NpcAssignment

        protected void NpcAssignment(byte type, List<byte> data)
        {
            byte[] packet = data.ToArray();
            NpcEntity output;
            //try
            //{
            BitReader br = new BitReader(data.ToArray());
            br.ReadBitsLittleEndian(8);
            UInt32 id = (uint)br.Read(32);
            UInt16 npctype = (ushort)br.Read(16);
            UInt16 x = (ushort)br.Read(16);
            UInt16 y = (ushort)br.Read(16);
            byte life = (byte)br.Read(8);
            byte size = (byte)br.Read(8);

            output = new NpcEntity(id, npctype, life, x, y);

            int informationLength = 16;

            String[] entries;

            if (!DataManager.Instance.m_monsterFields.Get(npctype, out entries))
                Logger.Write("Failed to read monstats data for NPC of type {0}", type);
            if (entries.Length != informationLength)
                Logger.Write("Invalid monstats entry for NPC of type {0}", type);

            bool lookupName = false;

            if (data.Count > 0x10)
            {
                br.Read(4);
                if (br.ReadBit())
                {
                    for (int i = 0; i < informationLength; i++)
                    {
                        int temp;

                        int value = Int32.Parse(entries[i]);

                        if (!BitScanReverse(out temp, (uint)value - 1))
                            temp = 0;
                        if (temp == 31)
                            temp = 0;

                        //Console.WriteLine("BSR: {0} Bitcount: {1}", temp+1, bitCount);
                        int bits = br.Read(temp + 1);
                    }
                }

                output.SuperUnique = false;

                output.HasFlags = br.ReadBit();
                if (output.HasFlags)
                {
                    output.Champion = br.ReadBit();
                    output.Unique = br.ReadBit();
                    output.SuperUnique = br.ReadBit();
                    output.IsMinion = br.ReadBit();
                    output.Ghostly = br.ReadBit();
                    //Console.WriteLine("{0} {1} {2} {3} {4}", output.Champion, output.Unique, output.SuperUnique, output.IsMinion, output.Ghostly);
                }

                if (output.SuperUnique)
                {
                    output.SuperUniqueId = br.ReadBitsLittleEndian(16);
                    String name;
                    if (!DataManager.Instance.m_superUniques.Get(output.SuperUniqueId, out name))
                    {
                        Logger.Write("Failed to lookup super unique monster name for {0}", output.SuperUniqueId);
                        output.Name = "invalid";
                    }
                    else
                    {
                        output.Name = name;
                        //Console.WriteLine("NPC: {0}", name);
                    }
                }
                else
                    lookupName = true;

                if (data.Count > 17 && lookupName != true && output.Name != "invalid")
                {
                    output.IsLightning = false;
                    while (true)
                    {
                        byte mod = (byte)br.ReadBitsLittleEndian(8);
                        if (mod == 0)
                            break;
                        if (mod == 0x11)
                            output.IsLightning = true;
                    }
                }
            }
            else
                lookupName = true;

            if (lookupName)
            {
                String name;
                if (!DataManager.Instance.m_monsterNames.Get((int)output.Type, out name))
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:OmegaBot,代码行数:101,代码来源:D2gsHandler.cs

示例12: Deserialize

        public static ActorStateProperty Deserialize(IClassNetCache classMap, string typeName, string[] objectIndexToName, UInt32 versionMajor, UInt32 versionMinor, BitReader br)
        {
            var asp = new ActorStateProperty();

            var maxPropId = classMap.MaxPropertyId;

            var className = objectIndexToName[classMap.ObjectIndex];
            asp.PropertyId = br.ReadUInt32Max(maxPropId + 1);
            #if DEBUG
            asp.MaxPropertyId = (UInt32)maxPropId;
            #endif
            asp.PropertyName = objectIndexToName[classMap.GetProperty((int)asp.PropertyId).Index];

            var startPosition = br.Position;

            asp.Data = new List<object>();

            switch (asp.PropertyName)
            {
                case "TAGame.GameEvent_TA:ReplicatedStateIndex":
                    asp.Data.Add(br.ReadUInt32Max(140)); // number is made up, I dont know the max yet // TODO: Revisit this. It might work well enough, but looks fishy
                    asp.MarkComplete();
                    break;
                case "TAGame.RBActor_TA:ReplicatedRBState":
                    asp.Data.Add(RigidBodyState.Deserialize(br));
                    asp.MarkComplete();
                    break;
                case "TAGame.CrowdActor_TA:ReplicatedOneShotSound":
                case "TAGame.CrowdManager_TA:ReplicatedGlobalOneShotSound":
                case "Engine.GameReplicationInfo:GameClass":
                case "TAGame.CrowdManager_TA:GameEvent":
                case "TAGame.CrowdActor_TA:GameEvent":
                case "TAGame.Team_TA:LogoData":
                case "TAGame.CameraSettingsActor_TA:PRI":
                case "TAGame.PRI_TA:PersistentCamera":
                case "TAGame.GameEvent_TA:MatchTypeClass":
                case "TAGame.GameEvent_Soccar_TA:SubRulesArchetype":
                    // Theres a good chance that most of these can be moved to the next section
                    asp.Data.Add(br.ReadBit());
                    asp.Data.Add(br.ReadUInt32());
                    asp.MarkComplete();
                    break;
                case "TAGame.Team_TA:GameEvent":
                case "TAGame.Ball_TA:GameEvent":
                case "Engine.PlayerReplicationInfo:Team":
                case "Engine.Pawn:PlayerReplicationInfo":
                case "TAGame.PRI_TA:ReplicatedGameEvent":
                case "TAGame.CarComponent_TA:Vehicle":
                case "TAGame.Car_TA:AttachedPickup":
                case "TAGame.SpecialPickup_Targeted_TA:Targeted":
                    // TODO: Use a real class so it can be accessed normally.
                    // If Active == false, ActorId will be -1
                    asp.Data.Add(ActiveActor.Deserialize(br));
                    asp.MarkComplete();
                    break;
                case "Engine.GameReplicationInfo:ServerName":
                case "Engine.PlayerReplicationInfo:PlayerName":
                case "TAGame.Team_TA:CustomTeamName":
                case "Engine.PlayerReplicationInfo:RemoteUserData":
                case "TAGame.GRI_TA:NewDedicatedServerIP":
                    asp.Data.Add(br.ReadString());
                    asp.MarkComplete();
                    break;
                case "TAGame.GameEvent_Soccar_TA:SecondsRemaining":
                case "TAGame.GameEvent_TA:ReplicatedGameStateTimeRemaining":
                case "TAGame.CrowdActor_TA:ReplicatedCountDownNumber":
                case "TAGame.GameEvent_Team_TA:MaxTeamSize":
                case "Engine.PlayerReplicationInfo:PlayerID":
                case "TAGame.PRI_TA:TotalXP":
                case "TAGame.PRI_TA:MatchScore":
                case "TAGame.GameEvent_Soccar_TA:RoundNum":
                case "TAGame.GameEvent_TA:BotSkill":
                case "TAGame.PRI_TA:MatchShots":
                case "TAGame.PRI_TA:MatchSaves":
                case "ProjectX.GRI_X:ReplicatedGamePlaylist":
                case "Engine.TeamInfo:Score":
                case "Engine.PlayerReplicationInfo:Score":
                case "TAGame.PRI_TA:MatchGoals":
                case "TAGame.PRI_TA:MatchAssists":
                case "ProjectX.GRI_X:ReplicatedGameMutatorIndex":
                case "TAGame.PRI_TA:Title":
                case "TAGame.GameEvent_TA:ReplicatedStateName":
                case "TAGame.Team_Soccar_TA:GameScore":
                case "TAGame.GameEvent_Soccar_TA:GameTime":
                case "TAGame.CarComponent_Boost_TA:UnlimitedBoostRefCount":
                case "TAGame.CrowdActor_TA:ReplicatedRoundCountDownNumber":
                    asp.Data.Add(br.ReadUInt32());
                    asp.MarkComplete();
                    break;
                case "TAGame.VehiclePickup_TA:ReplicatedPickupData":
                    asp.Data.Add(br.ReadBit());
                    asp.Data.Add(br.ReadUInt32());
                    asp.Data.Add(br.ReadBit());

                    asp.MarkComplete();
                    break;
                case "Engine.PlayerReplicationInfo:Ping":
                case "TAGame.Vehicle_TA:ReplicatedSteer":
                case "TAGame.Vehicle_TA:ReplicatedThrottle": // 0: full reverse, 128: No throttle.  255 full throttle/boosting
                case "TAGame.PRI_TA:CameraYaw":
//.........这里部分代码省略.........
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:101,代码来源:ActorStateProperty.cs

示例13: Deserialize

        public static ActorState Deserialize(int maxChannels, List<ActorState> existingActorStates, List<ActorState> frameActorStates, string[] objectIndexToName, IDictionary<string, ClassNetCache> classNetCacheByName, UInt32 versionMajor, UInt32 versionMinor, BitReader br)
        {
            var startPosition = br.Position;
            ActorState a = new ActorState();

            try
            {
                var actorId = br.ReadUInt32Max(maxChannels);

                a.Id = actorId;

                if (br.ReadBit())
                {
                    if (br.ReadBit())
                    {
                        a.State = ActorStateState.New;

                        if (versionMajor > 868 || (versionMajor == 868 && versionMinor >= 14))
                        {
                            a.NameId = br.ReadUInt32();
                        }

                        a.Unknown1 = br.ReadBit();
                        a.TypeId = br.ReadUInt32();

                        a.TypeName = objectIndexToName[(int)a.TypeId.Value];
                        a._classNetCache = ObjectNameToClassNetCache(a.TypeName, classNetCacheByName);
                        a.ClassName = objectIndexToName[a._classNetCache.ObjectIndex];

                        if ( !ClassHasInitialPosition(a.ClassName))
                        {
            #if DEBUG
                            a.KnownBits = br.GetBits(startPosition, br.Position - startPosition);
                            a.Complete = true;
            #endif
                            return a;
                        }

                        a.Position = Vector3D.Deserialize(br);

                        if (ClassHasRotation(a.ClassName))
                        {
                            a.Rotation = Rotator.Deserialize(br);
                        }
            #if DEBUG
                        a.Complete = true;
            #endif
                    }
                    else
                    {
                        a.State = ActorStateState.Existing;
                        var oldState = existingActorStates.Where(x => x.Id == a.Id).Single();

                        a.TypeId = oldState.TypeId;

                        a.Properties = new List<ActorStateProperty>();
                        ActorStateProperty lastProp = null;
                        while (br.ReadBit())
                        {
                            lastProp = ActorStateProperty.Deserialize(oldState._classNetCache, oldState.TypeName, objectIndexToName, versionMajor, versionMinor, br);
                            a.Properties.Add(lastProp);

            #if DEBUG
                            if (!lastProp.IsComplete)
                            {
                                break;
                            }
            #endif
                        }

            #if DEBUG
                        a.Complete = lastProp.IsComplete;
                        if (lastProp.Data.Count > 0 && lastProp.Data.Last().ToString() == "FAILED")
                        {
                            a.Failed = true;
                        }
            #endif
                        var endPosition = br.Position;
                    }
                }
                else
                {
                    a.State = ActorStateState.Deleted;

                    var actor = existingActorStates.Where(x => x.Id == a.Id).SingleOrDefault();
            #if DEBUG
                    a.Complete = true;
            #endif
                    var endPosition = br.Position;
                }
            #if DEBUG
                if (!a.Complete)
                {
                    // Read a bunch of data so we have something to look at in the logs
                    // Otherwise the logs may not show any data bits for whatever is broken, which is hard to interpret
                    br.ReadBytes(16);
                }

                a.KnownBits = br.GetBits(startPosition, br.Position - startPosition);
            #endif
//.........这里部分代码省略.........
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:101,代码来源:ActorState.cs

示例14: GetIdentifiedInfo

        public static void GetIdentifiedInfo(BitReader reader, ref Item item)
        {
            if (item.identified)
            {
                switch (item.quality)
                {
                    case Item.QualityType.inferior:
                        item.prefix = (byte)reader.Read(3);
                        break;
                    case Item.QualityType.superior:
                        item.superiority = (Item.SuperiorItemClassType)(reader.Read(3));
                        break;
                    case Item.QualityType.magical:
                        item.prefix = (uint)reader.Read(11);
                        item.suffix = (uint)reader.Read(11);
                        break;

                    case Item.QualityType.crafted:
                    case Item.QualityType.rare:
                        item.prefix = (uint)reader.Read(8) - 156;
                        item.suffix = (uint)reader.Read(8) - 1;
                        break;

                    case Item.QualityType.set:
                        item.set_code = (uint)reader.Read(12);
                        break;
                    case Item.QualityType.unique:
                        if (item.type != "std") //standard of heroes exception?
                            item.unique_code = (uint)reader.Read(12);
                        break;
                }
            }

            if (item.quality == Item.QualityType.rare || item.quality == Item.QualityType.crafted)
            {
                for (ulong i = 0; i < 3; i++)
                {
                    if (reader.ReadBit())
                        item.prefixes.Add((uint)reader.Read(11));
                    if (reader.ReadBit())
                        item.suffixes.Add((uint)reader.Read(11));
                }
            }

            if (item.rune_word)
            {
                item.runeword_id = (uint)reader.Read(12);
                item.runeword_parameter = (byte)reader.Read(4);
                //std::cout << "runeword_id: " << item.runeword_id << ", parameter: " << item.runeword_parameter << std::endl;
            }

            if (item.personalised)
            {
                List<Byte> personalised_name = new List<byte>();
                reader.Read(8);
                while (personalised_name.Last() != 0x00)
                {
                    reader.Read(8); // 16 characters of 7 bits each for the name of the ear to process later
                }
                item.personalised_name = Convert.ToBase64String(personalised_name.ToArray()); //this is also a problem part i'm not sure about

            }

            if (item.is_armor)
                item.defense = (uint)reader.Read(11) - 10;

            if (item.type == "7cr")
                reader.Read(8);
            else if (item.is_armor || item.is_weapon)
            {
                item.maximum_durability = (byte)reader.Read(8);
                item.indestructible = (uint)((item.maximum_durability == 0) ? 1 : 0);

                item.durability = (byte)reader.Read(8);
                reader.ReadBit();
            }
            if (item.has_sockets)
                item.sockets = (byte)reader.Read(4);
        }
开发者ID:uvbs,项目名称:OmegaBot,代码行数:79,代码来源:Parser.cs

示例15: Deserialize

        public static Frame Deserialize(int maxChannels, ref List<ActorState> existingActorStates, string[] objectIdToName, IDictionary<string, ClassNetCache> classNetCacheByName, UInt32 versionMajor, UInt32 versionMinor, BitReader br)
        {
            var f = new Frame();

            f.Position = br.Position;

            f.Time = br.ReadFloat();
            f.Delta = br.ReadFloat();

            if (f.Time < 0 || f.Delta < 0
                || (f.Time > 0 && f.Time < 1E-10)
                || (f.Delta > 0 && f.Delta < 1E-10))
            {
                string error = string.Format("\"Frame\" at postion {0} has time values that are negative or suspicious. The parser got lost. Check the previous frame for bad data. Time {1}, Delta {2}", f.Position, f.Time, f.Delta);
            #if DEBUG
                Console.WriteLine(error);
                f.Failed = true;
                return f;
            #endif
                throw new Exception(error);
            }

            f.ActorStates = new List<ActorState>();

            ActorState lastActorState = null;
            while (br.ReadBit())
            {
                lastActorState = ActorState.Deserialize(maxChannels, existingActorStates, f.ActorStates, objectIdToName, classNetCacheByName, versionMajor, versionMinor, br);

                var existingActor = existingActorStates.Where(x => x.Id == lastActorState.Id).SingleOrDefault();
                if (lastActorState.State != ActorStateState.Deleted)
                {
                    if (existingActor == null)
                    {
                        existingActorStates.Add(lastActorState);
                    }
                }
                else
                {
                    existingActorStates = existingActorStates.Where(x => x.Id != lastActorState.Id).ToList();
                }

                f.ActorStates.Add(lastActorState);

            #if DEBUG
                if(!lastActorState.Complete)
                {
                    break;
                }
            #endif
            }
            #if DEBUG
            if (lastActorState == null || lastActorState.Complete)
            {
                f.Complete = true;
            }

            if (lastActorState != null && lastActorState.Failed)
            {
                f.Failed = true;
            }

            f.RawData = br.GetBits(f.Position, br.Position - f.Position).ToArray();
            #endif
            return f;
        }
开发者ID:jjbott,项目名称:RocketLeagueReplayParser,代码行数:66,代码来源:Frame.cs


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