using System.IO;
using System.Runtime.InteropServices;

namespace MindPowerSdk
{
    /// <summary>
    /// 
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct MPMapFileHeader
    {
        /// <summary>
        /// 类型标识 = 780624
        /// </summary>
        public int MapFlag { get; private set; }

        /// <summary>
        /// 地图宽度
        /// </summary>
        public int Width { get; private set; }

        /// <summary>
        /// 地图高度
        /// </summary>
        public int Height { get; private set; }

        /// <summary>
        /// 每个Section(部分)宽度
        /// </summary>
        public int SectionWidth { get; private set; }

        /// <summary>
        /// 每个Section(部分)高度
        /// </summary>
        public int SectionHeight { get; private set; }

        public static MPMapFileHeader Load(BinaryReader reader)
        {
            MPMapFileHeader header = default;

            header.MapFlag = reader.ReadInt32();
            header.Width = reader.ReadInt32();
            header.Height = reader.ReadInt32();
            header.SectionWidth = reader.ReadInt32();
            header.SectionHeight = reader.ReadInt32();

            return header;
        }
    }
}