11package ru.octol1ttle.flightassistant.impl.display
22
33import com.mojang.math.Axis
4+ import kotlin.math.roundToInt
45import net.minecraft.client.gui.GuiGraphics
56import net.minecraft.network.chat.Component
67import net.minecraft.resources.ResourceLocation
@@ -16,9 +17,9 @@ import ru.octol1ttle.flightassistant.api.util.extensions.*
1617import ru.octol1ttle.flightassistant.config.FAConfig
1718
1819class FlightDirectorsDisplay (computers : ComputerBus ) : Display(computers) {
19- private val pitchTargetLerper : FloatLerper = FloatLerper ()
20- private val headingTargetLerper : FloatLerper = FloatLerper ()
21-
20+ private val xLerper : FloatLerper = FloatLerper ()
21+ private val yLerper : FloatLerper = FloatLerper ()
22+
2223 override fun allowedByConfig (): Boolean {
2324 return FAConfig .display.showFlightDirectors
2425 }
@@ -42,17 +43,15 @@ class FlightDirectorsDisplay(computers: ComputerBus) : Display(computers) {
4243 enableScissor(HudFrame .left, HudFrame .top, HudFrame .right, HudFrame .bottom)
4344
4445 val pitchInput: ControlInput ? = computers.pitch.activeInput
45- val pitchTarget: Float? = pitchTargetLerper.get(pitchInput?.target, FATickCounter .timePassed * 1.5f )
46- if (pitchTarget != null && pitchInput != null && pitchInput.priority >= ControlInput .Priority .NORMAL ) {
47- ScreenSpace .getY(pitchTarget)?.let {
46+ if (pitchInput != null && pitchInput.priority >= ControlInput .Priority .NORMAL ) {
47+ yLerper.get(ScreenSpace .getY(pitchInput.target)?.toFloat(), FATickCounter .timePassed * 1.5f )?.roundToInt()?.let {
4848 hLine(this .centerX - halfWidth, this .centerX + halfWidth, it.coerceIn(HudFrame .top + 1 .. <HudFrame .bottom - 1), primaryAdvisoryColor)
4949 }
5050 }
5151
5252 val headingInput: ControlInput ? = computers.heading.activeInput
53- val headingTarget: Float ? = headingTargetLerper.get(headingInput?.target, FATickCounter .timePassed * 1.5f)
54- if (headingTarget != null && headingInput != null && headingInput.priority >= ControlInput .Priority .NORMAL ) {
55- ScreenSpace .getX(headingTarget)?.let {
53+ if (headingInput != null && headingInput.priority >= ControlInput .Priority .NORMAL ) {
54+ xLerper.get(ScreenSpace .getX(headingInput.target)?.toFloat(), FATickCounter .timePassed * 1.5f )?.roundToInt()?.let {
5655 vLine(it.coerceIn(HudFrame .left + 1 .. <HudFrame .right - 1), this.centerY - halfWidth, this.centerY + halfWidth, primaryAdvisoryColor)
5756 }
5857 }
0 commit comments