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

namespace PSO2SERVER.Protocol.Packets
{
    public class EnemyKilledPacket : Packet
    {
        /// Player that receives this packet.
        public ObjectHeader Receiver { get; set; } = new ObjectHeader();
        /// Object that receives this damage.
        public ObjectHeader Dmg_target { get; set; } = new ObjectHeader();
        /// Object that deals this damage.
        public ObjectHeader Dmg_inflicter { get; set; } = new ObjectHeader();
        /// Inflicted damage ID.
        public uint Damage_id { get; set; } = 0;
        /// How much damage was inflicted.
        public int Dmg_amount { get; set; } = 0;
        /// New HP.
        public uint New_hp { get; set; } = 0;
        /// Hitbox ID (?).
        public uint Hitbox_id { get; set; } = 0;
        /// Hit x position.
        public Half X_pos { get; set; } = 0;
        /// Hit y position.
        public Half Y_pos { get; set; } = 0;
        /// Hit z position.
        public Half Z_pos { get; set; } = 0;
        public ushort unk1 { get; set; } = 0;
        public ushort unk2 { get; set; } = 0;
        public ushort unk3 { get; set; } = 0;
        public ushort unk4 { get; set; } = 0;
        public ushort unk5 { get; set; } = 0;
        public ushort unk6 { get; set; } = 0;
        public ushort unk7 { get; set; } = 0;

        public EnemyKilledPacket()
        {
        }

        #region implemented abstract members of Packet

        public override byte[] Build()
        {
            var pkt = new PacketWriter();
            pkt.WriteStruct(Receiver);
            pkt.WriteStruct(Dmg_target);
            pkt.WriteStruct(Dmg_inflicter);
            pkt.Write(Damage_id);
            pkt.Write(Dmg_amount);
            pkt.Write(New_hp);
            pkt.Write(Hitbox_id);
            pkt.WriteHalf(X_pos);
            pkt.WriteHalf(Y_pos);
            pkt.WriteHalf(Z_pos);
            pkt.Write(unk1);
            pkt.Write(unk2);
            pkt.Write(unk3);
            pkt.Write(unk4);
            pkt.Write(unk5);
            pkt.Write(unk6);
            pkt.Write(unk7);
            return pkt.ToArray();
        }

        public override PacketHeader GetHeader()
        {
            return new PacketHeader(0x04, 0x0F, PacketFlags.OBJECT_RELATED);
        }

        #endregion
    }
}