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

namespace PSO2SERVER.Protocol.Packets
{
    public class Unk4A03Packet : Packet
    {
        public uint Unk1; // 对应 Rust 的 u32
        public List<Mission> Unk2; // 使用 List 替代 Vec
        public List<uint> Unk3; // 使用 List 替代 Vec
        public List<Unk2Struct> Unk4; // 使用 List 替代 Vec
        public uint Unk5; // 对应 Rust 的 u32

        public Unk4A03Packet(uint unk1, List<Mission> unk2, List<uint> unk3, List<Unk2Struct> unk4, uint unk5)
        {
            Unk1 = unk1;
            Unk2 = unk2;
            Unk3 = unk3;
            Unk4 = unk4;
            Unk5 = unk5;
        }

        #region implemented abstract members of Packet

        public override byte[] Build()
        {
            var pkt = new PacketWriter();
            pkt.Write(Unk1);
            pkt.WriteMagic(Unk2.Count, 0xD20D, 0xDD);
            foreach (var mission in Unk2) {pkt.WriteStruct(mission);}

            pkt.WriteMagic(Unk3.Count, 0xD20D, 0xDD);
            foreach (var unk3 in Unk3) { pkt.WriteStruct(unk3); }

            pkt.WriteMagic(Unk4.Count, 0xD20D, 0xDD);
            foreach (var unk2 in Unk4) { pkt.WriteStruct(unk2); }

            pkt.Write(Unk5);
            return pkt.ToArray();
        }

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

        #endregion
    }
}