package net.taehui.twilight.note

import net.taehui.twilight.Component
import net.taehui.twilight.awilight.DefaultCompute
import net.taehui.twilight.note.JudgedNoteData.ID

class MeterNote(logicalY: Double, wait: Double) : BaseNote(logicalY, wait) {
    override val logicalLayer: Int
        get() = 3
    override val layer: Int
        get() = 0

    override fun judge(input: Int, wait: Double, judgmentStage: Double, isAutoLongNote: Boolean): JudgedNoteData? {
        return null
    }

    override fun autoJudge(wait: Double): JudgedNoteData? {
        if (this.wait <= wait) {
            judged = Component.Judged.HIGHEST
            return JudgedNoteData(ID.NOT, 0.0, judged)
        }
        return null
    }

    override fun paint(defaultComputer: DefaultCompute) {
        val multiplier = defaultComputer.modeComponentValue.getPaidMultiplier()
        if (multiplier > 0.0) {
            val y = getY(multiplier)
            if (y >= 0.0) {
                defaultComputer.netDrawings.add(
                    EventOuterClass.Event.NetDrawing.newBuilder().apply {
                        this.drawingVariety = EventOuterClass.Event.NetDrawing.Variety.Meter
                        this.param = 4294967295.toInt()
                        this.position1 = y
                    }.build()
                )
            }
        }
    }
}