本文整理汇总了C#中RealmPacketOut.Zero方法的典型用法代码示例。如果您正苦于以下问题:C# RealmPacketOut.Zero方法的具体用法?C# RealmPacketOut.Zero怎么用?C# RealmPacketOut.Zero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RealmPacketOut
的用法示例。
在下文中一共展示了RealmPacketOut.Zero方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendCharEnum
/// <summary>
/// Sends the character list to the client.
/// </summary>
/// <param name="client">the client to send to</param>
/// <remarks>They probably meant 'enumeration,' but 'list' would have made so much more sense. :)</remarks>
public static void SendCharEnum(IRealmClient client)
{
CharacterRecord curRecord = null;
try
{
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_ENUM))
{
var chrs = client.Account.Characters;
packet.WriteByte(chrs.Count);
foreach (var record in chrs)
{
curRecord = record;
packet.Write(EntityId.GetPlayerId(record.EntityLowId)); // 8
packet.WriteCString(record.Name); // 9 + namelength
packet.Write((byte)record.Race); // 10 + namelength
packet.Write((byte)record.Class); // 11 + namelength
packet.Write((byte)record.Gender); // 12 + namelength
packet.Write(record.Skin); // 13 + namelength
packet.Write(record.Face); // 14 + namelength
packet.Write(record.HairStyle); // 15 + namelength
packet.Write(record.HairColor); // 16 + namelength
packet.Write(record.FacialHair); // 17 + namelength
packet.Write((byte)record.Level); // 18 + namelength
packet.Write((int)record.Zone); // 22 + namelength
packet.Write((int)record.MapId); // 26 + namelength
packet.Write(record.PositionX); // 30 + namelength
packet.Write(record.PositionY); // 34 + namelength
packet.Write(record.PositionZ); // 38 + namelength
packet.WriteUInt(record.GuildId); // guild id // 42 + namelength
packet.Write((int)record.CharacterFlags); // 46 + namelength
packet.Write(0); // TOOD: Customization flags
packet.Write((byte)1); // NEW 3.2.0 - first login y/n - set to 1 for now
// Deprecated: Rest State
// var restState = record.RestXp > 0 ? RestState.Resting : RestState.Normal;
// packet.WriteByte((byte)restState); // 47 + namelength
// pet info (51 - 63)
var petEntry = record.PetEntry;
if (petEntry != null)
{
packet.Write(petEntry.DisplayIds[0]);
packet.Write(record.Level); // liars!
packet.Write((int)petEntry.FamilyId);
}
else
{
packet.Write(0); // 51 + namelength
packet.Write(0); // 55 + namelength
packet.Write(0); // 59 + namelength
}
var itemOffset = packet.Position;
//packet.TotalLength += CharEnumItemCount * CharEnumItemBytes; // 239 + namelength
packet.Zero(CharEnumItemCount * CharEnumItemBytes);
packet.Position = itemOffset;
if (record.JustCreated)
{
var archetype = ArchetypeMgr.GetArchetype(record.Race, record.Class);
if (archetype != null)
{
var items = archetype.GetInitialItems(record.Gender);
foreach (var item in items)
{
var template = item.Template;
if (template.EquipmentSlots != null)
{
packet.Position = itemOffset + ((int)template.EquipmentSlots[0] * CharEnumItemBytes);
packet.Write(template.DisplayId);
packet.Write((byte)template.InventorySlotType);
packet.Write(0);
}
}
}
else
{
log.Warn("Invalid Race/Class combination " +
"({0} {1}) in CharacterRecord {2}.",
record.Race, record.Class, record);
}
}
else
{
foreach (var item in record.GetOrLoadItems())
{
if (!item.IsOwned)
//.........这里部分代码省略.........
示例2: SendTradeUpdate
/// <summary>
/// Sends the new state of the trading window to other party
/// </summary>
/// <param name="otherParty">Whether this is sending the own info to the other party (or, if false, to oneself)</param>
/// <param name="client">receiving party</param>
/// <param name="money">new amount of money</param>
/// <param name="items">new items</param>
public static void SendTradeUpdate(IPacketReceiver client, bool otherParty, uint money, Item[] items)
{
using (var pkt = new RealmPacketOut(RealmServerOpCode.SMSG_TRADE_STATUS_EXTENDED, 30 + 18 * 4 * items.Length))
{
pkt.Write(otherParty);
pkt.Write(0); // Trade id
pkt.Write(items.Length);
pkt.Write(items.Length);
pkt.Write(money);
pkt.Write(0);
for (var i = 0; i < items.Length; i++)
{
pkt.WriteByte(i);
var item = items[i];
if (item != null)
{
pkt.Write(item.EntryId);
pkt.Write(item.Template.DisplayId);
pkt.Write(item.Amount);
pkt.Write(0);
pkt.Write(item.GiftCreator);
var enchant = item.GetEnchantment(EnchantSlot.Permanent);
pkt.Write(enchant != null ? enchant.Entry.Id : 0);
pkt.Zero(4 * 3);
pkt.Write(item.Creator);
pkt.Write(item.SpellCharges);
pkt.Write(item.Template.RandomSuffixFactor);
pkt.Write(item.RandomPropertiesId);
var itemLock = item.Lock;
pkt.Write(itemLock != null ? itemLock.Id : 0);
pkt.Write(item.MaxDurability);
pkt.Write(item.Durability);
}
else
{
pkt.Zero(18 * 4);
}
}
client.Send(pkt);
}
}
示例3: SendItemQueryResponse
public static void SendItemQueryResponse(IRealmClient client, ItemTemplate item)
{
var locale = client.Info.Locale;
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, 630))
{
packet.Write(item.Id);
packet.Write((uint)item.Class);
packet.Write((uint)item.SubClass);
packet.Write(-1); // unknown
packet.WriteCString(item.Names.Localize(locale));
packet.Write((byte)0);// name2
packet.Write((byte)0);// name3
packet.Write((byte)0);// name4
packet.Write(item.DisplayId);
packet.Write((uint)item.Quality);
packet.Write((uint)item.Flags);
packet.Write((uint)item.Faction); // new 3.2.0
packet.Write(item.BuyPrice);
packet.Write(item.SellPrice);
packet.Write((int)item.InventorySlotType);
packet.Write((uint)item.RequiredClassMask);
packet.Write((uint)item.RequiredRaceMask);
packet.Write(item.Level);
packet.Write(item.RequiredLevel);
packet.Write(item.RequiredSkill != null ? (int)item.RequiredSkill.Id : 0);
packet.Write(item.RequiredSkillValue);
packet.Write(item.RequiredProfession != null ? item.RequiredProfession.Id : 0);
packet.Write(item.RequiredPvPRank);
packet.Write(item.UnknownRank);// PVP Medal
packet.Write(item.RequiredFaction != null ? (int)item.RequiredFaction.Id : 0);
packet.Write((int)item.RequiredFactionStanding);
packet.Write(item.UniqueCount);
packet.Write(item.MaxAmount);
packet.Write(item.ContainerSlots);
packet.Write(item.Mods.Length);
for (var m = 0; m < item.Mods.Length; m++)
{
packet.Write((int) item.Mods[m].Type);
packet.Write(item.Mods[m].Value);
}
packet.Write(0);// NEW 3.0.2 ScalingStatDistribution.dbc
packet.Write(0);// NEW 3.0.2 ScalingStatFlags
// In 3.1 there are only 2 damages instead of 5
for (var i = 0; i < item.Damages.Length && i < 2; i++)
{
var dmg = item.Damages[i];
packet.Write(dmg.Minimum);
packet.Write(dmg.Maximum);
packet.Write((uint)dmg.School);
}
for (var i = 0; i < ItemConstants.MaxResCount; i++)
{
var res = item.Resistances[i];
packet.Write(res);
}
packet.Write(item.AttackTime);
packet.Write((uint)item.ProjectileType);
packet.Write(item.RangeModifier);
var s = 0;
for (; s < item.Spells.Length; s++)
{
var spell = item.Spells[s];
if (spell != null)
{
packet.Write((uint)spell.Id);
packet.Write((uint)spell.Trigger);
packet.Write(spell.Charges);
packet.Write(spell.Cooldown);
packet.Write(spell.CategoryId);
packet.Write(spell.CategoryCooldown);
}
else
{
// 6 * 4 = 24
packet.Zero(24);
}
}
for (; s < ItemConstants.MaxSpellCount; s++)
{
// 6 * 4 = 24
packet.Zero(24);
}
packet.Write((uint)item.BondType);
packet.WriteCString(item.Descriptions.Localize(locale));
packet.Write(item.PageTextId);
packet.Write(item.PageCount);
packet.Write((uint)item.PageMaterial);
//.........这里部分代码省略.........