當前位置: 首頁>>代碼示例>>C#>>正文


C# BitPack類代碼示例

本文整理匯總了C#中BitPack的典型用法代碼示例。如果您正苦於以下問題:C# BitPack類的具體用法?C# BitPack怎麽用?C# BitPack使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BitPack類屬於命名空間,在下文中一共展示了BitPack類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: HandleSendKnownSpells

        public static void HandleSendKnownSpells(ref WorldClass session)
        {
            Character pChar = session.Character;

            var specializationSpells = SpecializationMgr.GetSpecializationSpells(pChar);
            var specializationSpellCount = ((specializationSpells != null) ? specializationSpells.Count : 0);

            var talentSpells = SpecializationMgr.GetTalentSpells(pChar, pChar.ActiveSpecGroup);
            var talentSpellCount = ((talentSpells != null) ? talentSpells.Count : 0);

            int count = pChar.SpellList.Count + specializationSpellCount + talentSpellCount;

            PacketWriter writer = new PacketWriter(ServerMessage.SendKnownSpells);
            BitPack BitPack = new BitPack(writer);

            BitPack.Write(1);
            BitPack.Write(count, 22);
            BitPack.Flush();

            pChar.SpellList.ForEach(spell =>
                writer.WriteUInt32(spell.SpellId));

            if (specializationSpells != null)
                specializationSpells.ForEach(spell => writer.WriteUInt32(spell.Spell));

            if (talentSpells != null)
                talentSpells.ForEach(spell => writer.WriteUInt32(spell));

            session.Send(ref writer);
        }
開發者ID:RashKim,項目名稱:Arctium,代碼行數:30,代碼來源:SpellHandler.cs

示例2: HandleTalkToGossip

        public static void HandleTalkToGossip(ref PacketReader packet, ref WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            byte[] guidMask = { 3, 1, 7, 4, 6, 0, 2, 5 };
            byte[] guidBytes = { 0, 1, 7, 6, 5, 2, 4, 3 };

            var guid = BitUnpack.GetPackedValue(guidMask, guidBytes);
            var gossipData = GossipMgr.GetGossip<Creature>(SmartGuid.GetGuid(guid));

            if (gossipData != null)
            {
                PacketWriter gossipMessage = new PacketWriter(ServerMessage.GossipMessage);
                BitPack BitPack = new BitPack(gossipMessage, guid);

                BitPack.WriteGuidMask(0, 1);
                BitPack.Write(0, 19);           // gossipData.QuestsCount
                BitPack.WriteGuidMask(2);
                BitPack.Write(0, 20);           // gossipData.OptionsCount

                // QuestsCount not supported.
                // for (int i = 0; i < gossipData.QuestsCount; i++)

                BitPack.WriteGuidMask(3);

                // OptionsCount not supported.
                // for (int i = 0; i < gossipData.OptionsCount; i++)

                BitPack.WriteGuidMask(5, 4, 6, 7);

                BitPack.Flush();

                BitPack.WriteGuidBytes(6);

                // OptionsCount not supported.
                // for (int i = 0; i < gossipData.OptionsCount; i++)

                BitPack.WriteGuidBytes(0);

                // QuestsCount not supported.
                // for (int i = 0; i < gossipData.QuestsCount; i++)

                gossipMessage.WriteInt32(gossipData.Id);

                BitPack.WriteGuidBytes(4, 3);

                gossipMessage.WriteInt32(gossipData.FriendshipFactionID);
                gossipMessage.WriteInt32(gossipData.TextID);

                BitPack.WriteGuidBytes(7, 1, 5, 1);

                session.Send(ref gossipMessage);
            }
        }
開發者ID:OakCore,項目名稱:Arctium,代碼行數:54,代碼來源:GossipHandler.cs

示例3: HandleUnlearnedSpells

        public static void HandleUnlearnedSpells(ref WorldClass session, List<uint> oldSpells)
        {
            PacketWriter writer = new PacketWriter(ServerMessage.UnlearnedSpells);
            BitPack BitPack = new BitPack(writer);

            BitPack.Write<int>(oldSpells.Count, 22);
            BitPack.Flush();

            for (int i = 0; i < oldSpells.Count; i++)
                writer.WriteUInt32(oldSpells[i]);

            session.Send(ref writer);
        }
開發者ID:RashKim,項目名稱:Arctium,代碼行數:13,代碼來源:SpellHandler.cs

示例4: HandleMoveSetCanFly

        public static void HandleMoveSetCanFly(ref WorldClass session)
        {
            PacketWriter setCanFly = new PacketWriter(JAMCMessage.MoveSetCanFly);
            BitPack BitPack = new BitPack(setCanFly, session.Character.Guid);

            BitPack.WriteGuidMask(7, 3, 1, 5, 0, 6, 2, 4);
            BitPack.Flush();

            setCanFly.WriteUInt32(0);

            BitPack.WriteGuidBytes(2, 6, 7, 1, 3, 4, 6, 0);
            session.Send(setCanFly);
        }
開發者ID:Gargash,項目名稱:Arctium,代碼行數:13,代碼來源:MoveHandler.cs

示例5: HandleMoveSetCanFly

        public static void HandleMoveSetCanFly(ref WorldClass session)
        {
            PacketWriter moveSetCanFly = new PacketWriter(ServerMessage.MoveSetCanFly);
            BitPack BitPack = new BitPack(moveSetCanFly, session.Character.Guid);

            BitPack.WriteGuidMask(5, 3, 0, 2, 4, 1, 6, 7);
            BitPack.Flush();

            BitPack.WriteGuidBytes(1, 3, 5, 0, 7, 2, 4, 6);

            moveSetCanFly.WriteUInt32(0);

            session.Send(ref moveSetCanFly);
        }
開發者ID:OakCore,項目名稱:Arctium,代碼行數:14,代碼來源:MoveHandler.cs

示例6: HandleDestroyObject

        public static PacketWriter HandleDestroyObject(ref WorldClass session, ulong guid)
        {
            PacketWriter destroyObject = new PacketWriter(ServerMessage.DestroyObject);
            BitPack BitPack = new BitPack(destroyObject, guid);

            BitPack.WriteGuidMask(1, 6, 5, 7, 4, 2, 0, 3);
            BitPack.Write(0);

            BitPack.Flush();

            BitPack.WriteGuidBytes(7, 2, 6, 1, 3, 7, 5, 0);

            return destroyObject;
        }
開發者ID:xyin,項目名稱:Arctium,代碼行數:14,代碼來源:ObjectHandler.cs

示例7: HandleLearnedSpells

        public static void HandleLearnedSpells(ref WorldClass session, List<uint> newSpells)
        {
            PacketWriter writer = new PacketWriter(JAMCMessage.LearnedSpells);
            BitPack BitPack = new BitPack(writer);

            BitPack.Write(0);
            BitPack.Write<int>(newSpells.Count, 24);
            BitPack.Flush();

            for (int i = 0; i < newSpells.Count; i++)
                writer.WriteUInt32(newSpells[i]);

            session.Send(ref writer);
        }
開發者ID:Mathias1000,項目名稱:Arctium,代碼行數:14,代碼來源:SpellHandler.cs

示例8: HandleMoveSetRunSpeed

        public static void HandleMoveSetRunSpeed(ref WorldClass session, float speed = 7f)
        {
            PacketWriter setRunSpeed = new PacketWriter(JAMCMessage.MoveSetRunSpeed);
            BitPack BitPack = new BitPack(setRunSpeed, session.Character.Guid);

            BitPack.WriteGuidMask(0, 4, 1, 6, 3, 5, 7, 2);
            BitPack.Flush();

            setRunSpeed.WriteFloat(speed);
            BitPack.WriteGuidBytes(7);
            setRunSpeed.WriteUInt32(0);
            BitPack.WriteGuidBytes(3, 6, 0, 4, 1, 5, 2);

            session.Send(setRunSpeed);
        }
開發者ID:thundergod221,項目名稱:Arctium,代碼行數:15,代碼來源:MoveHandler.cs

示例9: HandleDestroyObject

        public static PacketWriter HandleDestroyObject(ref WorldClass session, ulong guid, bool animation = false)
        {
            PacketWriter destroyObject = new PacketWriter(ServerMessage.DestroyObject);
            BitPack BitPack = new BitPack(destroyObject, guid);

            BitPack.WriteGuidMask(7, 2, 6, 3, 1, 4);
            BitPack.Write(animation);
            BitPack.WriteGuidMask(5, 0);

            BitPack.Flush();

            BitPack.WriteGuidBytes(4, 3, 2, 7, 0, 1, 6, 5);

            return destroyObject;
        }
開發者ID:rodrigoalv,項目名稱:Arctium-WoW,代碼行數:15,代碼來源:ObjectHandler.cs

示例10: HandleSendKnownSpells

        public static void HandleSendKnownSpells(ref WorldClass session)
        {
            Character pChar = session.Character;

            PacketWriter writer = new PacketWriter(JAMCMessage.SendKnownSpells);
            BitPack BitPack = new BitPack(writer);

            BitPack.Write<uint>((uint)pChar.SpellList.Count, 24);
            BitPack.Write(1);
            BitPack.Flush();

            pChar.SpellList.ForEach(spell =>
                writer.WriteUInt32(spell.SpellId));

            session.Send(ref writer);
        }
開發者ID:jesus01,項目名稱:Arctium,代碼行數:16,代碼來源:SpellHandler.cs

示例11: HandleDBQueryBulk

        public static void HandleDBQueryBulk(ref PacketReader packet, ref WorldClass session)
        {
            var type = (DBTypes)packet.ReadUInt32();
            var unknown = packet.ReadInt32();
            var id = packet.ReadInt32();

            switch (type)
            {
                case DBTypes.BroadcastText:
                {
                    var broadCastText = GossipMgr.GetBroadCastText<Creature>(id);

                    PacketWriter dbReply = new PacketWriter(JAMCMessage.DBReply);
                    BitPack BitPack = new BitPack(dbReply);

                    var textLength = broadCastText.Text.Length;
                    var alternativeTextLength = broadCastText.AlternativeText.Length;
                    var size = 48;

                    if (textLength == 0 || alternativeTextLength == 0)
                        size += 1;

                    size += textLength + alternativeTextLength;

                    dbReply.WriteUInt32((uint)size);
                    dbReply.WriteInt32(broadCastText.Id);
                    dbReply.WriteInt32(broadCastText.Language);

                    dbReply.WriteUInt16((ushort)broadCastText.Text.Length);
                    dbReply.WriteString(broadCastText.Text);

                    dbReply.WriteUInt16((ushort)broadCastText.AlternativeText.Length);
                    dbReply.WriteString(broadCastText.AlternativeText);

                    broadCastText.Emotes.ForEach(emote => dbReply.WriteInt32(emote));

                    dbReply.WriteUInt32(1);

                    dbReply.WriteUInt32(0);    // UnixTime, last change server side
                    dbReply.WriteUInt32((uint)DBTypes.BroadcastText);
                    dbReply.WriteInt32(broadCastText.Id);

                    session.Send(ref dbReply);
                    break;
                }
            }
        }
開發者ID:Mathias1000,項目名稱:Arctium,代碼行數:47,代碼來源:GossipHandler.cs

示例12: HandleLogoutRequest

        public static void HandleLogoutRequest(ref PacketReader packet, WorldClass session)
        {
            PacketWriter logoutResponse = new PacketWriter(ServerMessage.LogoutResponse);
            BitPack BitPack = new BitPack(logoutResponse);

            logoutResponse.WriteUInt8(0);
            BitPack.Write(0);
            BitPack.Flush();

            session.Send(ref logoutResponse);

            Task.Delay(20000).ContinueWith(_ => HandleLogoutComplete(session), (cts = new CancellationTokenSource()).Token);

            session.Character.setStandState(1);

            MoveHandler.HandleMoveRoot(session);
        }
開發者ID:mansemino,項目名稱:Arctium,代碼行數:17,代碼來源:LogoutHandler.cs

示例13: HandleMoveSetFlightSpeed

        public static void HandleMoveSetFlightSpeed(ref WorldClass session, float speed = 7f)
        {
            PacketWriter setFlightSpeed = new PacketWriter(ServerMessage.MoveSetFlightSpeed);
            BitPack BitPack = new BitPack(setFlightSpeed, session.Character.Guid);

            BitPack.WriteGuidMask(5, 4, 2, 1, 7, 6, 3, 0);
            BitPack.Flush();

            setFlightSpeed.WriteUInt32(0);

            BitPack.WriteGuidBytes(5, 7);

            setFlightSpeed.WriteFloat(speed);

            BitPack.WriteGuidBytes(1, 2, 3, 6, 0, 4);

            session.Send(ref setFlightSpeed);
        }
開發者ID:OakCore,項目名稱:Arctium,代碼行數:18,代碼來源:MoveHandler.cs

示例14: SendSendKnownSpells

        public static void SendSendKnownSpells()
        {
            Character pChar = GetSession().Character;

            if (pChar.SpellList.Count == 0)
                SpellMgr.LoadSpells();

            PacketWriter writer = new PacketWriter(LegacyMessage.SendKnownSpells);
            BitPack BitPack = new BitPack(writer);

            BitPack.Write(1);
            BitPack.Write<uint>((uint)pChar.SpellList.Count, 24);
            BitPack.Flush();

            pChar.SpellList.ForEach(spell =>
                writer.WriteUInt32(spell.SpellId));

            GetSession().Send(writer);
        }
開發者ID:Gargash,項目名稱:Arctium,代碼行數:19,代碼來源:SpellHandler.cs

示例15: HandleRealmSplit

        public static void HandleRealmSplit(ref PacketReader packet, ref WorldClass session)
        {
            uint realmSplitState = 0;
            var date = "01/01/01";

            PacketWriter realmSplit = new PacketWriter(ServerMessage.RealmSplit);
            BitPack BitPack = new BitPack(realmSplit);

            BitPack.Write(date.Length, 7);
            realmSplit.WriteString(date);

            realmSplit.WriteUInt32(packet.Read<uint>());
            realmSplit.WriteUInt32(realmSplitState);

            session.Send(ref realmSplit);

            // Crash!!!
            // Wrong data sent...
            // AddonMgr.WriteAddonData(ref session);
        }
開發者ID:hellssiing,項目名稱:Arctium,代碼行數:20,代碼來源:TimeHandler.cs


注:本文中的BitPack類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。