protected override void OnPassengerAdd(Player player, VehicleSeatType seatType, byte seatPosition) { if (seatType != VehicleSeatType.Pilot) { return; } if (PilotDisplayInfo != null) { player.SetAppearance(new ItemVisual { Slot = ItemSlot.Mount, DisplayId = (ushort)PilotDisplayInfo.Id }); } PetCustomisation customisation = player.PetCustomisationManager.GetCustomisation(MountType, SpellEntry.Id); if (customisation != null) { ItemSlot slot = ItemSlot.MountFront; foreach (PetFlairEntry entry in customisation) { if (entry != null) { var itemVisual = new ItemVisual { Slot = slot, DisplayId = (ushort)(slot != ItemSlot.MountRight ? entry.ItemDisplayId[0] : entry.ItemDisplayId[1]) }; // hoverboards have their flair visuals added to the player if (MountType == PetType.HoverBoard) { player.SetAppearance(itemVisual); } else { SetAppearance(itemVisual); } } slot++; } } UpdateVisuals(player); }
/// <summary> /// Create a new <see cref="PetCustomisationManager"/> from existing <see cref="Character"/> database model. /// </summary> public PetCustomisationManager(Player owner, Character model) { player = owner; foreach (CharacterPetFlair flairModel in model.CharacterPetFlair) { var petFlair = new PetFlair(flairModel); petFlairs.Add(petFlair.Entry.Id, petFlair); } foreach (CharacterPetCustomisation customisationModel in model.CharacterPetCustomisation) { var customisation = new PetCustomisation(customisationModel); petCustomisations.Add(PetCustomisationHash(customisation.Type, customisation.ObjectId), customisation); } }
/// <summary> /// Add or update equipped pet flair at supplied index for <see cref="PetType"/> and object id. /// </summary> public void AddCustomisation(PetType type, uint objectId, ushort index, ushort flairId) { if (index >= MaxCustomisationFlairs) { throw new ArgumentOutOfRangeException(); } if (flairId != 0 && !petFlairs.ContainsKey(flairId)) { throw new ArgumentException(); } PetFlairEntry entry = GameTableManager.PetFlair.GetEntry(flairId); if (flairId != 0 && entry == null) { throw new ArgumentException(); } ulong hash = PetCustomisationHash(type, objectId); if (!petCustomisations.TryGetValue(hash, out PetCustomisation customisation)) { customisation = new PetCustomisation(player.CharacterId, type, objectId); petCustomisations.Add(hash, customisation); } customisation.AddFlair(index, entry); if (!player.IsLoading) { player.Session.EnqueueMessageEncrypted(new ServerPetCustomisation { PetCustomisation = new NetworkPetCustomisation { PetType = customisation.Type, PetObjectId = customisation.ObjectId, PetName = customisation.Name, SlotFlairIds = customisation .Select(f => f?.Id ?? 0) .ToArray() } }); } }