using PSO2SERVER.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PSO2SERVER.Protocol.Packets
{
    public class ItemAttributesPacket : Packet
    {

        /// Attribute ID (?) (seen only 0 or 1).
        public ushort Id { get; set; }

        /// Segment ID.
        public ushort Segment { get; set; }

        /// Total data size.
        public uint TotalSize { get; set; }

        /// ICE archive data segment.
        public byte[] Data { get; set; }

        // Constructor for convenience
        public ItemAttributesPacket(ushort id, ushort segment, uint totalSize, byte[] data)
        {
            Id = id;
            Segment = segment;
            TotalSize = totalSize;
            Data = data;
        }

        #region implemented abstract members of Packet

        public override byte[] Build()
        {
            var pkt = new PacketWriter();
            pkt.Write(Id);
            pkt.Write(Segment);
            pkt.Write(TotalSize);
            pkt.Write(Data);
            return pkt.ToArray();
        }

        public override PacketHeader GetHeader()
        {
            return new PacketHeader(0x0F, 0x00, PacketFlags.PACKED);
        }

        #endregion
    }
}