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

namespace PSO2SERVER.Protocol.Packets
{
    public class LoadingLevelPacket : Packet
    {
        private readonly string _file;

        /// Initial zone object.
        public ObjectHeader map_object { get; set; } = new ObjectHeader();
        /// Receiving player.
        public ObjectHeader receiver { get; set; } = new ObjectHeader();
        /// Settings for the initial zone (i.e. first zone that the player will appear in).
        public ZoneSettings settings { get; set; } = new ZoneSettings();
        public byte[] unk4 { get; set; } = new byte[0x0C];
        public byte[] unk5 { get; set; } = new byte[0x0C];
        public byte[] unk6 { get; set; } = new byte[0x0C];
        public string unk7 { get; set; } = string.Empty;//Ascii
        /// Settings for other zones.
        public List<ZoneSettings> other_settings { get; set; } = new List<ZoneSettings>();
        public List<WarpInfo> warps { get; set; } = new List<WarpInfo>();
        public List<LoadLevelThing3> unk10 { get; set; } = new List<LoadLevelThing3>();
        public List<LoadLevelThing4> unk11 { get; set; } = new List<LoadLevelThing4>();
        public List<LoadLevelThing5> unk12 { get; set; } = new List<LoadLevelThing5>();
        public List<LoadLevelThing6> unk13 { get; set; } = new List<LoadLevelThing6>();
        public List<LoadLevelThing7> unk14 { get; set; } = new List<LoadLevelThing7>();
        public List<LoadLevelThing8> unk15 { get; set; } = new List<LoadLevelThing8>();
        public List<UnkThing1> unk16 { get; set; } = new List<UnkThing1>();
        public string unk17 { get; set; } = string.Empty;//Ascii
        public uint unk18 { get; set; } = 0;
        public uint unk19 { get; set; } = 0;
        public uint unk20 { get; set; } = 0;
        // Fixed length array: C# doesn't have a direct equivalent, but we can use List<T> or byte[].
        // If the length is fixed, it's better to use byte[] and document its length.
        public List<byte> unk21 { get; set; } = new List<byte>(new byte[0x3C]);
        public uint unk22 { get; set; } = 0;
        public byte[] unk23 { get; set; } = new byte[0x10];
        public byte[] unk24 { get; set; } = new byte[0x10];
        public List<uint> unk25 { get; set; } = new List<uint> { };
        // Fixed length array: 0x200 bytes.
        public List<byte> unk26 { get; set; } = new List<byte>(new byte[0x200]);
        public List<UnkThing2> unk27 { get; set; } = new List<UnkThing2> { };
        public string unk28 { get; set; } = string.Empty;//Ascii
        public string unk29 { get; set; } = string.Empty;//Ascii
        public ulong unk30 { get; set; } = 0;
        public ulong unk31 { get; set; } = 0;
        public byte unk32 { get; set; } = 0;
        public byte unk33 { get; set; } = 0;
        public byte unk34 { get; set; } = 0;
        public byte unk35 { get; set; } = 0;
        public uint unk36 { get; set; } = 0;
        public byte[] unk37 { get; set; } = new byte[0x14];
        public ulong unk38 { get; set; } = 0;
        public uint unk39 { get; set; } = 0;
        public uint unk40 { get; set; } = 0;
        public byte[] unk41 { get; set; } = new byte[0x12];
        public ulong unk42 { get; set; } = 0;
        public byte unk43 { get; set; } = 0;
        public byte unk44 { get; set; } = 0;
        public List<LoadLevelThing9> unk45 { get; set; } = new List<LoadLevelThing9>();
        public string unk46 { get; set; } = string.Empty;//Ascii
        public List<LoadLevelThing10> unk47 { get; set; } = new List<LoadLevelThing10> { };
        public uint unk48 { get; set; } = 0;
        public byte[] unk49 { get; set; } = new byte[0x14];
        public byte[] unk50 { get; set; } = new byte[0x14];
        public uint unk51 { get; set; } = 0;

        public LoadingLevelPacket(string file)
        {
            _file = file;
        }

        public LoadingLevelPacket()
        {
        }

        #region implemented abstract members of Packet

        public override byte[] Build()
        {
            var setAreaPacket = File.ReadAllBytes("Resources\\quests\\" + _file + ".bin");
            return setAreaPacket;
        }

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

        #endregion
    }
}