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


C# BitPack.Write方法代码示例

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


在下文中一共展示了BitPack.Write方法的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: HandleLearnedSpells

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

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

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

            session.Send(ref writer);
        }
开发者ID:RashKim,项目名称:Arctium,代码行数:14,代码来源:SpellHandler.cs

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

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

示例6: HandleTalkToGossip

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

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

            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(7, 6, 0);
                BitPack.Write(0, 19);              // gossipData.QuestsCount
                BitPack.WriteGuidMask(4, 3, 2);
                BitPack.Write(0, 20);              // gossipData.OptionsCount
                BitPack.WriteGuidMask(1, 5);

                BitPack.Flush();

                BitPack.WriteGuidBytes(2, 7);

                gossipMessage.WriteInt32(gossipData.FriendshipFactionID);

                BitPack.WriteGuidBytes(3, 1);

                gossipMessage.WriteInt32(gossipData.TextID);

                BitPack.WriteGuidBytes(5);

                gossipMessage.WriteInt32(gossipData.Id);

                BitPack.WriteGuidBytes(6, 4, 0);

                session.Send(ref gossipMessage);
            }
        }
开发者ID:Kahath,项目名称:Arctium-WoW,代码行数:40,代码来源:GossipHandler.cs

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

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

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

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

示例11: HandleRealmSplit

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

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

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

            BitPack.Write(date.Length, 7);

            BitPack.Flush();

            realmSplit.WriteString(date);

            session.Send(ref realmSplit);

            AddonHandler.WriteAddonData(session);
        }
开发者ID:mansemino,项目名称:Arctium,代码行数:21,代码来源:TimeHandler.cs

示例12: HandleTransferPending

        public static void HandleTransferPending(ref WorldClass session, uint mapId)
        {
            bool Unknown = false;
            bool IsTransport = false;

            PacketWriter transferPending = new PacketWriter(ServerMessage.TransferPending);
            BitPack BitPack = new BitPack(transferPending);

            BitPack.Write(Unknown);
            BitPack.Write(IsTransport);

            BitPack.Flush();

            if (Unknown)
                transferPending.WriteUInt32(0);

            transferPending.WriteUInt32(mapId);

            if (IsTransport)
            {
                transferPending.WriteUInt32(0);
                transferPending.WriteUInt32(0);
            }

            session.Send(ref transferPending);
        }
开发者ID:rodrigoalv,项目名称:Arctium-WoW,代码行数:26,代码来源:MoveHandler.cs

示例13: HandleQueryCreature

        public static void HandleQueryCreature(ref PacketReader packet, ref WorldClass session)
        {
            var hasData = false;
            var id = packet.Read<int>();

            PacketWriter queryCreatureResponse = new PacketWriter(ServerMessage.QueryCreatureResponse);
            BitPack BitPack = new BitPack(queryCreatureResponse);

            queryCreatureResponse.WriteInt32(id);

            Creature creature = DataMgr.FindCreature(id);
            if (hasData = (creature != null))
            {
                CreatureStats stats = creature.Stats;

                BitPack.Write(hasData);
                BitPack.Write(stats.QuestItemId.Count, 22);
                BitPack.Write(0, 11);
                BitPack.Write(stats.RacialLeader);
                BitPack.Write(stats.IconName.Length + 1, 6);

                for (int i = 0; i < 8; i++)
                {
                    if (i == 1)
                        BitPack.Write(stats.Name.Length + 1, 11);
                    else
                        BitPack.Write(0, 11);
                }

                BitPack.Write(stats.SubName.Length != 0 ? stats.SubName.Length + 1 : 0, 11);
                BitPack.Flush();

                queryCreatureResponse.WriteInt32(stats.Rank);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[2]);
                queryCreatureResponse.WriteInt32(stats.Type);

                foreach (var v in stats.Flag)
                    queryCreatureResponse.WriteInt32(v);

                queryCreatureResponse.WriteFloat(stats.PowerModifier);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[0]);
                queryCreatureResponse.WriteFloat(1);

                queryCreatureResponse.WriteCString(stats.Name);

                if (stats.IconName != "")
                    queryCreatureResponse.WriteCString(stats.IconName);

                queryCreatureResponse.WriteInt32(stats.Family);
                queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[0]);

                if (stats.SubName != "")
                    queryCreatureResponse.WriteCString(stats.SubName);

                queryCreatureResponse.WriteInt32(stats.MovementInfoId);
                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[1]);
                queryCreatureResponse.WriteFloat(1);
                queryCreatureResponse.WriteFloat(stats.HealthModifier);
                queryCreatureResponse.WriteInt32(0);

                foreach (var v in stats.QuestItemId)
                    queryCreatureResponse.WriteInt32(v);

                queryCreatureResponse.WriteInt32(stats.DisplayInfoId[3]);
                queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[1]);
                queryCreatureResponse.WriteInt32(stats.ExpansionRequired);

                session.Send(ref queryCreatureResponse);
            }
            else
            {
                BitPack.Write(hasData);
                Log.Message(LogType.DEBUG, "Creature (Id: {0}) not found.", id);
            }
        }
开发者ID:ArkantosWoW,项目名称:ArkantosEmu,代码行数:75,代码来源:CacheHandler.cs

示例14: HandleMoveTeleport

        public static void HandleMoveTeleport(ref WorldClass session, Vector4 vector)
        {
            bool IsTransport = false;
            bool Unknown = false;

            PacketWriter moveTeleport = new PacketWriter(ServerMessage.MoveTeleport);
            BitPack BitPack = new BitPack(moveTeleport, session.Character.Guid);

            BitPack.WriteGuidMask(7);
            BitPack.Write(Unknown);
            BitPack.WriteGuidMask(2, 0);

            if (Unknown)
            {
                BitPack.Write(0);
                BitPack.Write(0);
            }

            BitPack.Write(IsTransport);

            if (IsTransport)
                BitPack.WriteTransportGuidMask(4, 3, 5, 7, 0, 2, 6, 1);

            BitPack.WriteGuidMask(5, 1, 3, 6, 4);

            BitPack.Flush();

            BitPack.WriteGuidBytes(0);

            if (IsTransport)
                BitPack.WriteTransportGuidBytes(7, 6, 0, 2, 3, 1, 5, 4);

            BitPack.WriteGuidBytes(6, 1);

            moveTeleport.WriteUInt32(0);

            BitPack.WriteGuidBytes(7, 5);

            moveTeleport.WriteFloat(vector.X);

            BitPack.WriteGuidBytes(4, 3, 2);

            moveTeleport.WriteFloat(vector.Y);
            moveTeleport.WriteFloat(vector.O);
            moveTeleport.WriteFloat(vector.Z);

            if (Unknown)
                moveTeleport.WriteUInt8(0);

            session.Send(ref moveTeleport);
        }
开发者ID:rodrigoalv,项目名称:Arctium-WoW,代码行数:51,代码来源:MoveHandler.cs

示例15: HandleMoveUpdate

        public static void HandleMoveUpdate(ulong guid, ObjectMovementValues movementValues, Vector4 vector)
        {
            PacketWriter moveUpdate = new PacketWriter(ServerMessage.MoveUpdate);
            BitPack BitPack = new BitPack(moveUpdate, guid);

            moveUpdate.WriteFloat(vector.Y);
            moveUpdate.WriteFloat(vector.Z);
            moveUpdate.WriteFloat(vector.X);

            BitPack.WriteGuidMask(5);
            BitPack.Write(0);
            BitPack.WriteGuidMask(3);
            BitPack.Write(0);
            BitPack.Write(1);
            BitPack.Write(!movementValues.HasMovementFlags2);
            BitPack.WriteGuidMask(0);
            BitPack.Write(1);
            BitPack.Write(!movementValues.HasRotation);
            BitPack.WriteGuidMask(7);
            BitPack.Write(movementValues.IsTransport);
            BitPack.Write(0);
            BitPack.Write(movementValues.Time == 0);
            BitPack.Write(!movementValues.HasMovementFlags);
            BitPack.WriteGuidMask(2);
            BitPack.Write(1);
            BitPack.Write(movementValues.IsFallingOrJumping);
            BitPack.WriteGuidMask(1, 6);
            BitPack.Write<uint>(0, 22);
            BitPack.WriteGuidMask(4);

            if (movementValues.IsFallingOrJumping)
                BitPack.Write(movementValues.HasJumpData);

            if (movementValues.HasMovementFlags)
                BitPack.Write((uint)movementValues.MovementFlags, 30);

            if (movementValues.HasMovementFlags2)
                BitPack.Write((uint)movementValues.MovementFlags2, 13);

            BitPack.Flush();

            if (movementValues.IsFallingOrJumping)
            {
                if (movementValues.HasJumpData)
                {
                    moveUpdate.WriteFloat(movementValues.CurrentSpeed);
                    moveUpdate.WriteFloat(movementValues.Sin);
                    moveUpdate.WriteFloat(movementValues.Cos);
                }

                moveUpdate.WriteFloat(movementValues.JumpVelocity);
                moveUpdate.WriteUInt32(movementValues.FallTime);
            }

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

            if (movementValues.Time != 0)
                moveUpdate.WriteUInt32(movementValues.Time);

            if (movementValues.HasRotation)
                moveUpdate.WriteFloat(vector.O);

            BitPack.WriteGuidBytes(6, 3);

            var session = WorldMgr.GetSession(guid);
            if (session != null)
            {
                Character pChar = session.Character;

                ObjectMgr.SetPosition(ref pChar, vector, false);
                WorldMgr.SendToInRangeCharacter(pChar, moveUpdate);
            }
        }
开发者ID:rodrigoalv,项目名称:Arctium-WoW,代码行数:73,代码来源:MoveHandler.cs


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