using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper.Plugins;

namespace skyscraper5.T2MI.Packets
{
	[SkyscraperPlugin]
	[T2MiPacketType(0x32)]
    internal class _0x32_Composite : T2MiPacket
    {
        public _0x32_Composite(T2MIHeader header, byte[] buffer) : base(header, buffer)
        {
            if (buffer.Length != 8)
            {
                Valid = false;
                return;
            }
            FefIndex = buffer[0];
            S1Field = (buffer[1] & 0x70) >> 4;
            S2Field = (buffer[1] & 0x0f);

            (buffer[6], buffer[7]) = (buffer[7], buffer[6]);
            NumSubparts = BitConverter.ToUInt16(buffer, 6);
            Valid = true;
        }

        public ushort NumSubparts { get; set; }

        public int S2Field { get; set; }

        public int S1Field { get; private set; }

        public byte FefIndex { get; private set; }
    }
}
