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

namespace PSO2SERVER.Protocol.Packets
{
    public class MinimapRevealPacket : Packet
    {
        /// World object where revealing was done.
        private ObjectHeader world {  get; set; }
        /// Receivers party object (?).
        private ObjectHeader party {  get; set; }
        private uint zone_id { get; set; }
        /// Bitset of revealed regions.
        private RevealedRegions revealed_zones { get; set; } = new RevealedRegions();

        // 构造函数，允许在创建时初始化字段
        public MinimapRevealPacket(ObjectHeader world, ObjectHeader party, uint zone_id, byte[] revealed_zones)
        {
            this.world = world;
            this.party = party;
            this.zone_id = zone_id;
            this.revealed_zones = new RevealedRegions(revealed_zones);
        }

        #region implemented abstract members of Packet

        public override byte[] Build()
        {
            var pkt = new PacketWriter();
            pkt.WriteStruct(world);
            pkt.WriteStruct(party);
            pkt.Write(zone_id);
            revealed_zones.Write(pkt);
            return pkt.ToArray();
        }

        public override PacketHeader GetHeader()
        {
            return new PacketHeader(0x0B, 0x13, PacketFlags.None);
        }

        #endregion
    }
}