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


package engine.net.client.msg;


import engine.exception.SerializationException;
import engine.net.AbstractConnection;
import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter;
import engine.net.client.Protocol;

public class DeleteItemMsg extends ClientNetMsg {

    private int type;
    private int objectUUID;
    private int unknown1, unknown2;

    public DeleteItemMsg(int type, int objectUUID) {
        super(Protocol.DELETEOBJECT);
        this.type = type;
        this.objectUUID = objectUUID;
        this.unknown1 = 0;
        this.unknown2 = 0;
    }

    /**
     * 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 DeleteItemMsg(AbstractConnection origin, ByteBufferReader reader) {
        super(Protocol.DELETEOBJECT, origin, reader);
    }

    /**
     * Deserializes the subclass specific items from the supplied NetMsgReader.
     */
    @Override
    protected void _deserialize(ByteBufferReader reader) {
        this.type = reader.getInt();
        this.objectUUID = reader.getInt();
        this.unknown1 = reader.getInt();
        this.unknown2 = reader.getInt();
    }

    /**
     * Serializes the subclass specific items to the supplied NetMsgWriter.
     */
    @Override
    protected void _serialize(ByteBufferWriter writer) throws SerializationException {
        writer.putInt(this.type);
        writer.putInt(this.objectUUID);
        writer.putInt(this.unknown1);
        writer.putInt(this.unknown2);
    }

    /**
     * @return the type
     */
    public int getType() {
        return type;
    }

    /**
     * @return the objectUUID
     */
    public int getUUID() {
        return objectUUID;
    }

}
