//  • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
//  ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
//  ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
//  ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
//  ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
//      Magicbane Emulator Project © 2013 - 2026
//                https://www.magicbane.com


package engine.net.client.msg;


import engine.mbEnums;
import engine.net.AbstractConnection;
import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter;
import engine.net.Protocol;
import engine.objects.AbstractCharacter;

public class TransferItemFromInventoryToEquipMsg extends ClientNetMsg {

    private int sourceType;
    private int sourceID;
    private int pad1;
    private int templateID;
    private int type;
    private int objectUUID;

    public mbEnums.EquipSlotType slot;
    private int pad2;
    private float unknown1, unknown2;

    /**
     * This is the general purpose constructor.
     */
    public TransferItemFromInventoryToEquipMsg() {
        super(Protocol.EQUIP);
    }

    public TransferItemFromInventoryToEquipMsg(AbstractCharacter source, mbEnums.EquipSlotType slot, int templateID) {
        super(Protocol.EQUIP);
        this.sourceType = source.getObjectType().ordinal();
        this.sourceID = source.getObjectUUID();
        this.slot = slot;
        this.templateID = templateID;
    }

    /**
     * This constructor is used by NetMsgFactory. It attempts to deserialize the
     * ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
     * past the limit) then this constructor Throws that Exception to the
     * caller.
     */
    public TransferItemFromInventoryToEquipMsg(AbstractConnection origin, ByteBufferReader reader) {
        super(Protocol.EQUIP, origin, reader);
    }

    /**
     * Serializes the subclass specific items to the supplied NetMsgWriter.
     */
    @Override
    protected void _deserialize(ByteBufferReader reader) {
        this.sourceType = reader.getInt();
        this.sourceID = reader.getInt();
        pad1 = reader.getInt();
        templateID = reader.getInt();
        type = reader.getInt();
        objectUUID = reader.getInt();
        slot = mbEnums.EquipSlotType.values()[reader.getInt()];
        pad2 = reader.getInt();
        unknown1 = reader.getFloat();
        unknown2 = reader.getFloat();
    }

    /**
     * Deserializes the subclass specific items from the supplied NetMsgReader.
     */
    @Override
    protected void _serialize(ByteBufferWriter writer) {
        writer.putInt(this.sourceType);
        writer.putInt(this.sourceID);
        writer.putInt(pad1);
        writer.putInt(templateID);
        writer.putInt(type);
        writer.putInt(objectUUID);
        writer.putInt(slot.ordinal());
        writer.putInt(pad2);
        writer.putFloat(unknown1);
        writer.putFloat(unknown1);
    }

    public int getTemplateID() {
        return templateID;
    }

    public void setTemplateID(int templateID) {
        this.templateID = templateID;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getUUID() {
        return objectUUID;
    }

    public float getUnknown1() {
        return unknown1;
    }

    public void setUnknown1(float unknown1) {
        this.unknown1 = unknown1;
    }

    public int getSourceType() {
        return sourceType;
    }

    public void setSourceType(int sourceType) {
        this.sourceType = sourceType;
    }

    public int getSourceID() {
        return sourceID;
    }

    public void setSourceID(int sourceID) {
        this.sourceID = sourceID;
    }

}
