本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}