本文整理汇总了C#中Packet.ReadEnum方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.ReadEnum方法的具体用法?C# Packet.ReadEnum怎么用?C# Packet.ReadEnum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.ReadEnum方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GameobjectQueryResponse
public static void GameobjectQueryResponse(Packet packet)
{
GameObject go = new GameObject();
var entry = packet.ReadEntryKey("Entry");
go.Entry = entry.Key;
if (entry.Value)
return;
go.Type = packet.ReadEnum<GameObjectType>("Type");
go.DisplayID = packet.ReadInt32("Display ID");
for (var i = 0; i < 4; i++)
go.Name[i] = packet.ReadCString("Name " + i);
go.IconName = packet.ReadCString("Icon Name");
go.CastCaption = packet.ReadCString("Cast Caption");
go.UnkString = packet.ReadCString("Unk String");
for (var i = 0; i < 32; i++)
go.Data[i] = packet.ReadInt32("Data " + i);
go.Size = packet.ReadSingle("Size");
for (var i = 0; i < 6; i++)
go.QuestItems[i] = packet.ReadInt32("Quest Item " + i);
go.Exp = packet.ReadInt32("Expansion ID");
GameObjectStorage.GetSingleton().Add(go);
}
示例2: HandleCreatureQueryResponse
public static void HandleCreatureQueryResponse(Packet packet)
{
Creature c = new Creature();
var entry = packet.ReadEntryKey("Entry");
if (entry.Value)
return;
c.Entry = entry.Key;
for (var i = 0; i < 4; i++)
c.Name[i] = packet.ReadCString("Name " + i);
for (var i = 0; i < 4; i++)
c.Name[i] = packet.ReadCString("Unk string " + i);
c.SubName = packet.ReadCString("Sub Name");
c.IconName = packet.ReadCString("Icon Name");
c.TypeFlags = packet.ReadEnum<CreatureTypeFlag>("Type Flags");
c.Type = packet.ReadEnum<CreatureType>("Type");
c.Family = packet.ReadEnum<CreatureFamily>("Family");
int val = packet.ReadInt32("Unk int");
c.Rank = packet.ReadEnum<CreatureRank>("Rank");
c.KillCredit1 = packet.ReadInt32("Kill Credit 1");
c.KillCredit2 = packet.ReadInt32("Kill Credit 2");
for (var i = 0; i < 4; i++)
c.DisplayIDs[i] = packet.ReadInt32("Display ID " + i);
c.HealthModifier = packet.ReadSingle("Health Modifier");
c.ManaModifier = packet.ReadSingle("Mana Modifier");
c.RacialLeader = packet.ReadBoolean("Racial Leader");
for (var i = 0; i < 6; i++)
c.QuestItems[i] = packet.ReadInt32("Quest Item " + i);
c.MovementID = packet.ReadInt32("Movement ID");
c.Exp = packet.ReadInt32("Expansion ID");
CreatureStorage.GetSingleton().Add(c);
}
示例3: HandleReqUpdateAccountData
public static void HandleReqUpdateAccountData(Packet packet)
{
packet.ReadEnum<AccountDataType>("Type");
packet.ReadTime("Time");
int inflatedSize = packet.ReadInt32("Size");
byte[] compressedData = packet.ReadBytes((int)packet.GetLength() - (int)packet.GetPosition());
byte[] data = new byte[inflatedSize];
var inflater = new Inflater();
inflater.SetInput(compressedData, 0, compressedData.Length);
inflater.Inflate(data, 0, inflatedSize);
Console.WriteLine("Data: {0}", encoder.GetString(data));
}
示例4: ReadMovementUpdateBlock
public static MovementInfo ReadMovementUpdateBlock(Packet packet, Guid guid)
{
var moveInfo = new MovementInfo();
var flags = packet.ReadEnum<UpdateFlag>("Update Flags");
if (flags.HasFlag(UpdateFlag.Living))
{
moveInfo = MovementHandler.ReadMovementInfo(packet, guid);
var moveFlags = moveInfo.Flags;
for (var i = 0; i < 9; i++)
{
var j = (SpeedType)i;
var speed = packet.ReadSingle();
Console.WriteLine(j + " Speed: " + speed);
switch (j)
{
case SpeedType.Walk:
{
moveInfo.WalkSpeed = speed / 2.5f;
break;
}
case SpeedType.Run:
{
moveInfo.RunSpeed = speed / 7.0f;
break;
}
}
}
if (moveFlags.HasFlag(MoveFlag.SplineEnabled))
{
var splineFlags = packet.ReadEnum<SplineFlag>("Spline Flags");
if (splineFlags.HasFlag(SplineFlag.FinalPoint))
packet.ReadVector3("Final Spline Coords");
if (splineFlags.HasFlag(SplineFlag.FinalTarget))
packet.ReadGuid("Final Spline Target GUID");
if (splineFlags.HasFlag(SplineFlag.FinalOrientation))
packet.ReadSingle("Final Spline Orientation");
packet.ReadInt32("Spline Time");
packet.ReadInt32("Spline Full Time");
packet.ReadInt32("Spline Unk Int32 1");
packet.ReadSingle("Spline Duration Multiplier");
packet.ReadSingle("Spline Unit Interval");
packet.ReadSingle("Spline Unk Float 2");
packet.ReadInt32("Spline Height Time");
var splineCount = packet.ReadInt32("Spline Count");
for (var i = 0; i < splineCount; i++)
packet.ReadVector3("Spline Waypoint " + i);
packet.ReadEnum<SplineMode>("Spline Mode");
packet.ReadVector3("Spline Endpoint");
}
}
else
{
if (flags.HasFlag(UpdateFlag.GOPosition))
{
packet.ReadPackedGuid("GO Position GUID");
var gopos = packet.ReadVector3("GO Position");
packet.ReadVector3("GO Transport Position");
var goFacing = packet.ReadSingle("GO Orientation");
moveInfo.Position = gopos;
moveInfo.Orientation = goFacing;
packet.ReadSingle("GO Transport Orientation");
}
else if (flags.HasFlag(UpdateFlag.StationaryObject))
packet.ReadVector4("Stationary Position");
}
if (flags.HasFlag(UpdateFlag.LowGuid))
packet.ReadInt32("Low GUID");
if (flags.HasFlag(UpdateFlag.AttackingTarget))
packet.ReadPackedGuid("Target GUID");
if (flags.HasFlag(UpdateFlag.Transport))
packet.ReadInt32("Transport Creation Time");
if (flags.HasFlag(UpdateFlag.Vehicle))
{
packet.ReadInt32("Vehicle ID");
packet.ReadSingle("Vehicle Orientation");
}
if (flags.HasFlag(UpdateFlag.GORotation))
packet.ReadPackedQuaternion("GO Rotation");
if (flags.HasFlag(UpdateFlag.Unknown2))
{
packet.ReadInt16("Unk Int16 1");
packet.ReadInt16("Unk Int16 2");
packet.ReadInt16("Unk Int16 3");
//.........这里部分代码省略.........
示例5: ReadCreateObjectBlock
public static void ReadCreateObjectBlock(Packet packet, Guid guid, short map)
{
var objType = packet.ReadEnum<ObjectType>("Object Type");
var moves = ReadMovementUpdateBlock(packet, guid);
var updates = ReadValuesUpdateBlock(packet);
var obj = new WowObject(guid, objType, moves);
obj.Position = moves.Position;
if (!Objects.ContainsKey(map))
Objects.Add(map, new Dictionary<Guid, WowObject>());
Objects[map].Add(guid, obj);
HandleUpdateFieldChangedValues(true, guid, objType, updates, moves);
}
示例6: HandleUpdateObject
public static void HandleUpdateObject(Packet packet)
{
var map = packet.ReadInt16("Map");
var count = packet.ReadInt32("Count");
long sposition = packet.GetPosition();
var unkByte = packet.ReadByte();
if (unkByte != 3)
packet.SetPosition(sposition);
else
{
Console.WriteLine("firstType: " + unkByte);
var guidCount = packet.ReadInt32("GUID Count");
if (guidCount > 0) {
for (uint i = 0; i < guidCount; i++)
packet.ReadPackedGuid("GUID " + (i + 1));
}
}
for (var i = 0; i < (count - ((unkByte == 3) ? 1 : 0)); i++)
{
var type = packet.ReadEnum<UpdateType>("Update Type #" + (i + 1));
switch (type)
{
case UpdateType.Values:
{
var guid = packet.ReadPackedGuid("GUID");
var updates = ReadValuesUpdateBlock(packet);
WowObject obj;
if (Objects.ContainsKey(map) && Objects[map].TryGetValue(guid, out obj))
HandleUpdateFieldChangedValues(false, guid, obj.Type, updates, obj.Movement);
break;
}
case UpdateType.Movement:
{
var guid = packet.ReadPackedGuid("GUID");
packet.ReadEnum<ObjectType>("Object type");
ReadMovementUpdateBlock(packet, guid);
ReadValuesUpdateBlock(packet);
break;
}
case UpdateType.CreateObject1:
case UpdateType.CreateObject2:
{
var guid = packet.ReadPackedGuid("GUID");
ReadCreateObjectBlock(packet, guid, map);
break;
}
case UpdateType.FarObjects:
case UpdateType.NearObjects:
{
var objCount = packet.ReadInt32("Object Count");
for (var j = 0; j < objCount; j++)
packet.ReadPackedGuid("Object GUID");
break;
}
}
}
}
示例7: HandleMessageChat
public static void HandleMessageChat(Packet packet)
{
var type = packet.ReadEnum<ChatMessageType>("Type");
packet.ReadEnum<Language>("Language");
packet.ReadGuid("GUID");
packet.ReadInt32("Unk Int32");
switch (type)
{
case ChatMessageType.Say:
case ChatMessageType.Yell:
case ChatMessageType.Party:
case ChatMessageType.PartyLeader:
case ChatMessageType.Raid:
case ChatMessageType.RaidLeader:
case ChatMessageType.RaidWarning:
case ChatMessageType.Guild:
case ChatMessageType.Officer:
case ChatMessageType.Emote:
case ChatMessageType.TextEmote:
case ChatMessageType.Whisper:
case ChatMessageType.WhisperInform:
case ChatMessageType.System:
case ChatMessageType.Channel:
case ChatMessageType.Battleground:
case ChatMessageType.BattlegroundNeutral:
case ChatMessageType.BattlegroundAlliance:
case ChatMessageType.BattlegroundHorde:
case ChatMessageType.BattlegroundLeader:
case ChatMessageType.Achievement:
case ChatMessageType.GuildAchievement:
{
if (type == ChatMessageType.Channel)
packet.ReadCString("Channel Name");
packet.ReadGuid("Sender GUID");
break;
}
case ChatMessageType.MonsterSay:
case ChatMessageType.MonsterYell:
case ChatMessageType.MonsterParty:
case ChatMessageType.MonsterEmote:
case ChatMessageType.MonsterWhisper:
case ChatMessageType.RaidBossEmote:
case ChatMessageType.RaidBossWhisper:
case ChatMessageType.BattleNet:
{
packet.ReadInt32("Name Length");
packet.ReadCString("Name");
var target = packet.ReadGuid("Receiver GUID");
break;
}
}
packet.ReadInt32("Text Length");
packet.ReadCString("Text");
packet.ReadEnum<ChatTag>("Chat Tag");
if (type != ChatMessageType.Achievement && type != ChatMessageType.GuildAchievement)
return;
packet.ReadInt32("Achievement ID");
}
示例8: HandleQuestQueryResponse
public static void HandleQuestQueryResponse(Packet packet)
{
Quest q = new Quest();
q.Entry = packet.ReadInt32("Entry");
q.Method = packet.ReadEnum<QuestMethod>("Method");
q.Level = packet.ReadInt32("Level");
q.MinLevel = packet.ReadInt32("MinLevel");
var sort = packet.ReadInt32();
if (sort >= 0)
Console.WriteLine("Zone: {0}", sort);
else
Console.WriteLine("Sort: {0}", (QuestSort)(-sort));
q.ZoneOrSort = sort;
q.Type = packet.ReadEnum<QuestType>("Type");
q.SuggestedPlayers = packet.ReadInt32("SuggestedPlayers");
q.RepObjectiveFaction1 = packet.ReadInt32("RepObjFaction1");
q.RepObjectiveValue1 = packet.ReadInt32("RepObjValue1");
q.RepObjectiveFaction2 = packet.ReadInt32("RepObjFaction2");
q.RepObjectiveValue2 = packet.ReadInt32("RepObjValue2");
q.NextQuestID = packet.ReadInt32("NextQuestID");
q.XPID = packet.ReadInt32("XPID");
q.RewardMoney = packet.ReadInt32("Money");
q.RewardMoneyAtMaxLevel = packet.ReadInt32("MoneyAtMaxLevel");
q.Spell = packet.ReadInt32("Spell");
q.SpellCast = packet.ReadInt32("SpellCast");
q.Honor = packet.ReadInt32("Honor");
q.HonorMultiplier = packet.ReadSingle("Honor (2)");
q.SourceItemID = packet.ReadInt32("Source Item ID");
q.Flags = packet.ReadEnum<QuestFlag>("Flags");
q.Unk = packet.ReadInt32("Unk");
q.RewardTitleID = packet.ReadInt32("RewardTitleID");
q.PlayersSlain = packet.ReadInt32("PlayersSlain");
q.RewardTalentPoints = packet.ReadInt32("RewardTalentPoints");
q.RewardArenaPoints = packet.ReadInt32("RewardArenaPoints");
q.RewardSkillLineID = packet.ReadInt32("RewardSkillLineID");
q.RewardSkillPoints = packet.ReadInt32("RewardSkillPoints");
q.RewardFactionMask = packet.ReadInt32("RewardFactionMask");
q.QuestGiverPortraitID = packet.ReadInt32("QuestGiverPortraitID");
q.QuestTurnInPortraitID = packet.ReadInt32("QuestTurnInPortraitID");
for (int i = 0; i < 4; i++)
{
q.RewardItem[i] = packet.ReadInt32("RewardItem[" + i + "]");
q.RewardItemCount[i] = packet.ReadInt32("RewardItemCount[" + i + "]");
}
for (int i = 0; i < 6; i++)
{
q.RewardItemChoice[i] = packet.ReadInt32("RewardItemChoice[" + i + "]");
q.RewardItemChoiceCount[i] = packet.ReadInt32("RewardItemChoiceCount[" + i + "]");
}
for (int i = 0; i < 5; i++)
q.RewardRepFactionID[i] = packet.ReadInt32("RewardRepFactionID[" + i + "]");
for (int i = 0; i < 5; i++)
q.RewardRepValueID[i] = packet.ReadInt32("RewardRepValueID[" + i + "]");
for (int i = 0; i < 5; i++)
q.RewardRepValue[i] = packet.ReadInt32("RewardRepValue[" + i + "]");
q.PointMapID = packet.ReadInt32("PointMapID");
q.PointX = packet.ReadSingle("PointX");
q.PointY = packet.ReadSingle("PointY");
q.PointOption = packet.ReadInt32("PointOption");
q.Title = packet.ReadCString("Title");
q.ObjectiveText = packet.ReadCString("ObjectiveText");
q.Description = packet.ReadCString("Description");
q.EndText = packet.ReadCString("EndText");
q.CompletionText = packet.ReadCString("CompletionText");
for (int i = 0; i < 4; i++)
{
q.RequiredCreatureOrGOID[i] = packet.ReadInt32("RequiredCreatureOrGOID[" + i + "]");
q.RequiredCreatureOrGOCount[i] = packet.ReadInt32("RequiredCreatureOrGOCount[" + i + "]");
q.ItemDropIntermediateID[i] = packet.ReadInt32("ItemDropIntermediateID[" + i + "]");
q.ItemDropIntermediateCount[i] = packet.ReadInt32("ItemDropIntermediateCount[" + i + "]");
}
for (int i = 0; i < 6; i++)
{
q.RequiredItemID[i] = packet.ReadInt32("RequiredItemID[" + i + "]");
q.RequiredItemCount[i] = packet.ReadInt32("RequiredItemCount[" + i + "]");
}
q.CriteriaSpellID = packet.ReadInt32("CriteriaSpellID");
for (int i = 0; i < 4; i++)
q.ObjectiveTexts[i] = packet.ReadCString("ObjectiveTexts[" + i + "]");
for (int i = 0; i < 4; i++)
{
q.RewardCurrencyID[i] = packet.ReadInt32("RewardCurrencyID[" + i + "]");
q.RewardCurrencyValue[i] = packet.ReadInt32("RewardCurrencyValue[" + i + "]");
}
for (int i = 0; i < 4; i++)
{
q.RequiredCurrencyID[i] = packet.ReadInt32("RequiredCurrencyID[" + i + "]");
q.RequiredCurrencyValue[i] = packet.ReadInt32("RequiredCurrencyValue[" + i + "]");
}
q.QuestGiverPortraitText = packet.ReadCString("QuestGiverPortraitText");
q.QuestGiverPortraitUnk = packet.ReadCString("QuestGiverPortraitUnk");
q.QuestTurnInPortraitText = packet.ReadCString("QuestTurnInPortraitText");
q.QuestTurnInPortraitUnk = packet.ReadCString("QuestTurnInPortrainUnk");
q.SoundField1 = packet.ReadInt32("Sound field 1");
q.SoundField2 = packet.ReadInt32("Sound field 2");
QuestStorage.GetSingleton().Add(q);
}
示例9: HandleNameQueryResponse
public static void HandleNameQueryResponse(Packet packet)
{
packet.ReadPackedGuid("GUID");
var end = packet.ReadBoolean("Name Found");
if (end)
return;
packet.ReadCString("Name");
packet.ReadCString("Realm Name");
var race = packet.ReadEnum<Race>("Race");
var gender = packet.ReadEnum<Gender>("Gender");
var cClass = packet.ReadEnum<Class>("Class");
var decline = packet.ReadBoolean("Name Declined");
if (!decline)
return;
for (var i = 0; i < 5; i++)
packet.ReadCString("Declined Name " + i);
}
示例10: ParseMonsterMovePackets
public static void ParseMonsterMovePackets(Packet packet)
{
var guid = packet.ReadPackedGuid("GUID");
if (packet.GetOpcode() == (ushort)Opcode.SMSG_MONSTER_MOVE_TRANSPORT)
{
packet.ReadPackedGuid("Transport GUID");
packet.ReadByte("Transport Seat");
}
packet.ReadBoolean("Unk Boolean");
var pos = packet.ReadVector3("Position");
packet.ReadInt32("Move Ticks");
var type = packet.ReadEnum<SplineType>("Spline Type");
switch (type)
{
case SplineType.FacingSpot:
{
packet.ReadVector3("Facing Spot");
break;
}
case SplineType.FacingTarget:
{
packet.ReadGuid("Facing GUID");
break;
}
case SplineType.FacingAngle:
{
packet.ReadSingle("Facing Angle");
break;
}
case SplineType.Stop:
{
return;
}
}
var flags = packet.ReadEnum<SplineFlag>("Spline Flags");
if (flags.HasFlag(SplineFlag.Unknown3)) {
packet.ReadEnum<MoveAnimationState>("Animation State");
packet.ReadInt32("Unk Int32 1");
}
packet.ReadInt32("Move Time");
if (flags.HasFlag(SplineFlag.Trajectory)) {
packet.ReadSingle("Unk Single");
packet.ReadInt32("Unk Int32 2");
}
var waypoints = packet.ReadInt32("Waypoints");
var newpos = packet.ReadVector3("Waypoint 0");
if (flags.HasFlag(SplineFlag.Flying) || flags.HasFlag(SplineFlag.CatmullRom)) {
for (var i = 0; i < waypoints - 1; i++) {
packet.ReadVector3("Waypoint " + (i + 1));
}
}
else {
var mid = new Vector3();
mid.X = (pos.X + newpos.X) * 0.5f;
mid.Y = (pos.Y + newpos.Y) * 0.5f;
mid.Z = (pos.Z + newpos.Z) * 0.5f;
for (var i = 0; i < waypoints - 1; i++) {
var vec = packet.ReadPackedVector3();
vec.X += mid.X;
vec.Y += mid.Y;
vec.Z += mid.Z;
Console.WriteLine("Waypoint " + (i + 1) + ": " + vec);
}
}
}
示例11: ReadMovementInfo
public static MovementInfo ReadMovementInfo(Packet packet, Guid guid)
{
bool HaveTransportData = false,
HaveTransportTime2 = false,
HaveTransportTime3 = false,
HavePitch = false,
HaveFallData = false,
HaveFallDirection = false,
HaveSplineElevation = false,
UnknownBool = false;
var info = new MovementInfo();
info.Flags = packet.ReadEnum<MoveFlag>("Movement Flags", 30);
var flags2 = packet.ReadEnum<MoveFlagExtra>("Extra Movement Flags", 12);
if (HaveTransportData = packet.ReadBit())
{
HaveTransportTime2 = packet.ReadBit();
HaveTransportTime3 = packet.ReadBit();
}
HavePitch = packet.ReadBit();
if (HaveFallData = packet.ReadBit())
HaveFallDirection = packet.ReadBit();
HaveSplineElevation = packet.ReadBit();
UnknownBool = packet.ReadBit();
packet.ReadGuid("GUID");
packet.ReadInt32("Time");
var pos = packet.ReadVector4("Position");
info.Position = new Vector3(pos.X, pos.Y, pos.Z);
info.Orientation = pos.O;
if (HaveTransportData)//info.Flags.HasFlag(MoveFlag.OnTransport))
{
packet.ReadGuid("Transport GUID");
packet.ReadVector4("Transport Position");
packet.ReadByte("Transport Seat");
packet.ReadInt32("Transport Time");
if (HaveTransportTime2)//flags2.HasFlag(MoveFlagExtra.InterpolatedPlayerMovement))
packet.ReadInt32("Transport Time 2");
if (HaveTransportTime3)
packet.ReadInt32("Transport Time 3");
}
if (HavePitch)//info.Flags.HasAnyFlag(MoveFlag.Swimming | MoveFlag.Flying) ||
//flags2.HasFlag(MoveFlagExtra.AlwaysAllowPitching))
packet.ReadSingle("Swim Pitch");
if (HaveFallData) // info.Flags.HasFlag(MoveFlag.Falling)
{
packet.ReadInt32("Fall Time");
packet.ReadSingle("Jump Velocity");
if (HaveFallDirection)
{
packet.ReadSingle("Jump Sin");
packet.ReadSingle("Jump Cos");
packet.ReadSingle("Jump XY Speed");
}
}
if (HaveSplineElevation) //info.Flags.HasFlag(MoveFlag.SplineElevation))
packet.ReadSingle("Spline Elevation");
return info;
}
示例12: HandleReqAccountData
public static void HandleReqAccountData(Packet packet)
{
packet.ReadEnum<AccountDataType>("Type");
}
示例13: ReadMovementInfo
public static MovementInfo ReadMovementInfo(Packet packet, Guid guid)
{
var info = new MovementInfo();
info.Flags = packet.ReadEnum<MoveFlag>("Movement Flags");
var flags2 = packet.ReadEnum<MoveFlagExtra>("Extra Movement Flags");
packet.ReadInt32("Time");
var pos = packet.ReadVector4("Position");
info.Position = new Vector3(pos.X, pos.Y, pos.Z);
info.Orientation = pos.O;
if (info.Flags.HasFlag(MoveFlag.OnTransport))
{
packet.ReadPackedGuid("Transport GUID");
packet.ReadVector4("Transport Position");
packet.ReadInt32("Transport Time");
packet.ReadByte("Transport Seat");
if (flags2.HasFlag(MoveFlagExtra.InterpolatedPlayerMovement))
packet.ReadInt32("Transport Time 2");
}
if (info.Flags.HasAnyFlag(MoveFlag.Swimming | MoveFlag.Flying) ||
flags2.HasFlag(MoveFlagExtra.AlwaysAllowPitching))
packet.ReadSingle("Swim Pitch");
packet.ReadInt32("Fall Time");
if (info.Flags.HasFlag(MoveFlag.Falling))
{
packet.ReadSingle("Jump Velocity");
packet.ReadSingle("Jump Sin");
packet.ReadSingle("Jump Cos");
packet.ReadSingle("Jump XY Speed");
}
if (info.Flags.HasFlag(MoveFlag.SplineElevation))
packet.ReadSingle("Spline Elevation");
return info;
}