本文整理匯總了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);
}
}