本文整理汇总了C#中WCell.RealmServer.Entities.NPC.BuildPetActionBar方法的典型用法代码示例。如果您正苦于以下问题:C# NPC.BuildPetActionBar方法的具体用法?C# NPC.BuildPetActionBar怎么用?C# NPC.BuildPetActionBar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WCell.RealmServer.Entities.NPC
的用法示例。
在下文中一共展示了NPC.BuildPetActionBar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendSpells
/// <summary>
/// Sends any kind of extra command-bar to control other entities, such as NPCs, vehicles etc
/// </summary>
/// <param name="owner"></param>
//public static void SendSpells(Character owner, NPC npc, uint duration,
// PetAttackMode attackMode, PetAction action, PetFlags flags,
// PetActionEntry[] petActions,
// PetSpell[] spells)
public static void SendSpells(Character owner, NPC pet, PetAction currentAction)
{
// TODO: Cooldowns
var record = pet.PetRecord;
var mode = pet.Entry.Type == CreatureType.NonCombatPet ? PetAttackMode.Passive : PetAttackMode.Defensive;
var flags = PetFlags.None;
uint[] actions = null;
if(record != null)
{
mode = record.AttackMode;
flags = record.Flags;
actions = record.ActionButtons;
}
if (actions == null)
actions = pet.BuildPetActionBar();
using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PET_SPELLS, 20 + (PetConstants.PetActionCount * 4) + 1 + (pet.Spells.Count) + 1 + (0)))
{
packet.Write(pet.EntityId);
packet.Write((ushort)pet.Entry.FamilyId);
packet.Write(pet.RemainingDecayDelayMillis); // duration
packet.Write((byte)mode);
packet.Write((byte)currentAction);
packet.Write((ushort)flags);
for (var i = 0; i < PetConstants.PetActionCount; i++)
{
var action = actions[i];
packet.Write(action);
}
var spellPos = packet.Position;
++packet.Position;
var spellCount = 0;
foreach (var spell in pet.Spells)
{
if (!spell.IsPassive)
{
packet.Write((ushort)spell.Id);
packet.Write((ushort)PetSpellState.Enabled);
++spellCount;
}
}
packet.Write((byte)0); // TODO: Cooldowns
packet.Position = spellPos;
packet.Write((byte)spellCount);
owner.Send(packet);
}
}