using Mysqlx.Crud;
using Mysqlx.Session;
using Org.BouncyCastle.Utilities;
using PSO2SERVER.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.Remoting.Contexts;
using System.Text;

namespace PSO2SERVER.Protocol.Packets
{
    public class MovementActionServerPacket : Packet
    {
        private readonly int _user_playerid;
        private readonly ObjectHeader _preformer;
        private readonly byte[] _preData;
        private readonly string _command;
        private readonly byte[] _rest;
        private readonly uint _thingCount;
        private readonly byte[] _things;
        private readonly byte[] _final;
        public MovementActionServerPacket(int user_playerid, ObjectHeader preformer, byte[] preData
            , string command, byte[] rest, uint thingCount, byte[] things, byte[] final
            )
        {
            _user_playerid = user_playerid;
            _preformer = preformer;
            _preData = preData;
            _command = command;
            _rest = rest;
            _thingCount = thingCount;
            _things = things;
            _final = things;
        }

        #region implemented abstract members of Packet

        public override byte[] Build()
        {
            PacketWriter pkt = new PacketWriter();
            pkt.WriteStruct(new ObjectHeader((uint)_user_playerid, ObjectType.Player));
            pkt.WriteStruct(_preformer);
            pkt.Write(_preData);
            pkt.WriteAscii(_command, 0x4315, 0x7A);
            pkt.Write(_rest);
            pkt.WriteMagic(_thingCount, 0x4315, 0x7A);
            pkt.Write(_things);
            pkt.Write(_final);

            return pkt.ToArray();
        }

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

        #endregion
    }
}