package org.cloudburstmc.protocol.bedrock.packet;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.cloudburstmc.protocol.bedrock.data.camera.*;
import org.cloudburstmc.protocol.common.PacketSignal;
import org.cloudburstmc.protocol.common.util.OptionalBoolean;

@Data
@EqualsAndHashCode(doNotUseGetters = true)
@ToString(doNotUseGetters = true)
public class CameraInstructionPacket implements BedrockPacket {
    public CameraSetInstruction setInstruction;
    public CameraFadeInstruction fadeInstruction;
    public OptionalBoolean clear = OptionalBoolean.empty();
    /**
     * @since v712
     */
    public CameraTargetInstruction targetInstruction;
    /**
     * @since v712
     */
    public OptionalBoolean removeTarget = OptionalBoolean.empty();
    /**
     * @since v827
     */
    public CameraFovInstruction fovInstruction;
    /**
     * @since v859
     */
    public CameraSplineInstruction splineInstruction;
    /**
     * @since v859
     */
    public CameraAttachToEntityInstruction attachInstruction;
    /**
     * @since v859
     */
    public OptionalBoolean detachFromEntity = OptionalBoolean.empty();

    @Override
    public PacketSignal handle(BedrockPacketHandler handler) {
        return handler.handle(this);
    }

    @Override
    public BedrockPacketType getPacketType() {
        return BedrockPacketType.CAMERA_INSTRUCTION;
    }

    public void setClear(boolean value) {
        this.clear = OptionalBoolean.of(value);
    }

    public void setClear(OptionalBoolean clear) {
        this.clear = clear;
    }

    @Override
    public CameraInstructionPacket clone() {
        try {
            return (CameraInstructionPacket) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new AssertionError(e);
        }
    }
}

