// Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; using Game.Entities; using System.Collections.Generic; namespace Game.Networking.Packets { class UpdateTalentData : ServerPacket { public UpdateTalentData() : base(ServerOpcodes.UpdateTalentData, ConnectionType.Instance) { } public override void Write() { _worldPacket.WriteUInt8(Info.ActiveGroup); _worldPacket.WriteUInt32(Info.PrimarySpecialization); _worldPacket.WriteInt32(Info.TalentGroups.Count); foreach (var talentGroupInfo in Info.TalentGroups) { _worldPacket.WriteUInt32(talentGroupInfo.SpecID); _worldPacket.WriteInt32(talentGroupInfo.TalentIDs.Count); _worldPacket.WriteInt32(talentGroupInfo.PvPTalents.Count); foreach (var talentID in talentGroupInfo.TalentIDs) _worldPacket.WriteUInt16(talentID); foreach (PvPTalent talent in talentGroupInfo.PvPTalents) talent.Write(_worldPacket); } } public TalentInfoUpdate Info = new(); public class TalentGroupInfo { public uint SpecID; public List TalentIDs = new(); public List PvPTalents = new(); } public class TalentInfoUpdate { public byte ActiveGroup; public uint PrimarySpecialization; public List TalentGroups = new(); } } class LearnTalents : ClientPacket { public LearnTalents(WorldPacket packet) : base(packet) { } public override void Read() { uint count = _worldPacket.ReadBits(6); for (int i = 0; i < count; ++i) Talents[i] = _worldPacket.ReadUInt16(); } public Array Talents = new(PlayerConst.MaxTalentTiers); } class RespecWipeConfirm : ServerPacket { public RespecWipeConfirm() : base(ServerOpcodes.RespecWipeConfirm) { } public override void Write() { _worldPacket.WriteInt8((sbyte)RespecType); _worldPacket.WriteUInt32(Cost); _worldPacket.WritePackedGuid(RespecMaster); } public ObjectGuid RespecMaster; public uint Cost; public SpecResetType RespecType; } class ConfirmRespecWipe : ClientPacket { public ConfirmRespecWipe(WorldPacket packet) : base(packet) { } public override void Read() { RespecMaster = _worldPacket.ReadPackedGuid(); RespecType = (SpecResetType)_worldPacket.ReadUInt8(); } public ObjectGuid RespecMaster; public SpecResetType RespecType; } class LearnTalentFailed : ServerPacket { public LearnTalentFailed() : base(ServerOpcodes.LearnTalentFailed) { } public override void Write() { _worldPacket.WriteBits(Reason, 4); _worldPacket.WriteInt32(SpellID); _worldPacket.WriteInt32(Talents.Count); foreach (var talent in Talents) _worldPacket.WriteUInt16(talent); } public uint Reason; public int SpellID; public List Talents = new(); } class ActiveGlyphs : ServerPacket { public ActiveGlyphs() : base(ServerOpcodes.ActiveGlyphs) { } public override void Write() { _worldPacket.WriteInt32(Glyphs.Count); foreach (GlyphBinding glyph in Glyphs) glyph.Write(_worldPacket); _worldPacket.WriteBit(IsFullUpdate); _worldPacket.FlushBits(); } public List Glyphs = new(); public bool IsFullUpdate; } class LearnPvpTalents : ClientPacket { public LearnPvpTalents(WorldPacket packet) : base(packet) { } public override void Read() { uint size = _worldPacket.ReadUInt32(); for (int i = 0; i < size; ++i) Talents[i] = new PvPTalent(_worldPacket); } public Array Talents = new(4); } class LearnPvpTalentFailed : ServerPacket { public LearnPvpTalentFailed() : base(ServerOpcodes.LearnPvpTalentFailed) { } public override void Write() { _worldPacket.WriteBits(Reason, 4); _worldPacket.WriteUInt32(SpellID); _worldPacket.WriteInt32(Talents.Count); foreach (var pvpTalent in Talents) pvpTalent.Write(_worldPacket); } public uint Reason; public uint SpellID; public List Talents = new(); } //Structs public struct PvPTalent { public ushort PvPTalentID; public byte Slot; public PvPTalent(WorldPacket data) { PvPTalentID = data.ReadUInt16(); Slot = data.ReadUInt8(); } public void Write(WorldPacket data) { data.WriteUInt16(PvPTalentID); data.WriteUInt8(Slot); } } struct GlyphBinding { public GlyphBinding(uint spellId, ushort glyphId) { SpellID = spellId; GlyphID = glyphId; } public void Write(WorldPacket data) { data.WriteUInt32(SpellID); data.WriteUInt16(GlyphID); } uint SpellID; ushort GlyphID; } }