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


package engine.net.client.msg;


import engine.net.AbstractConnection;
import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter;
import engine.net.Protocol;
import engine.objects.AbstractGameObject;

public class SetObjectValueMsg extends ClientNetMsg {
    private int targetType;
    private int targetID;
    private int msgType;
    private AbstractGameObject ago;


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

    public SetObjectValueMsg() {
        super(Protocol.SETOBJVAL);
    }

    public SetObjectValueMsg(AbstractGameObject ago, int type) {
        super(Protocol.SETOBJVAL);
        if (ago == null)
            return;
        this.msgType = type;
        this.targetType = ago.getObjectType().ordinal();
        this.targetID = ago.getObjectUUID();
        this.ago = ago;

    }

    /**
     * Deserializes the subclass specific items from the supplied NetMsgReader.
     */
    @Override
    protected void _deserialize(ByteBufferReader reader) {

    }

    /**
     * Serializes the subclass specific items to the supplied NetMsgWriter.
     */
    @Override
    protected void _serialize(ByteBufferWriter writer) {
        writer.putInt(this.targetType);
        writer.putInt(this.targetID);
        writer.putInt(0);
        writer.putInt(0);
        writer.putInt(msgType);
        writer.putInt(0);
    }


    public AbstractGameObject getAgo() {
        return ago;
    }

    public void setAgo(AbstractGameObject ago) {
        this.ago = ago;
    }

    public int getTargetType() {
        return targetType;
    }

    public void setTargetType(int targetType) {
        this.targetType = targetType;
    }

    public int getTargetID() {
        return targetID;
    }

    public void setTargetID(int targetID) {
        this.targetID = targetID;
    }

}
