Skip to content

Commit 2668ebc

Browse files
committed
fix a/thr not disconnecting on manual input
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
1 parent f288b60 commit 2668ebc

File tree

5 files changed

+8
-31
lines changed

5 files changed

+8
-31
lines changed

src/main/kotlin/ru/octol1ttle/flightassistant/api/util/MathHelper.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ru.octol1ttle.flightassistant.api.util
22

3-
import kotlin.math.*
3+
import kotlin.math.PI
44

55
fun degrees(value: Float): Float {
66
return (value * (180.0f / PI)).toFloat()
@@ -18,14 +18,6 @@ fun radians(value: Double): Double {
1818
return (value * (PI / 180.0))
1919
}
2020

21-
fun furtherFromZero(value: Float): Int {
22-
return if (value < 0.0f) {
23-
floor(value).toInt()
24-
} else {
25-
ceil(value).toInt()
26-
}
27-
}
28-
2921
fun Float.requireFinite(): Float {
3022
require(this.isFinite()) {
3123
"Float value invalid; expected finite value, got $this"

src/main/kotlin/ru/octol1ttle/flightassistant/api/util/extensions/CollectionExtensions.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,3 @@ fun List<AlertData>.getHighestPriority(): List<AlertData> {
3030
fun <T> List<T>.filterWorking(): List<T> {
3131
return this.filter { it !is Computer || !it.isDisabledOrFaulted() }
3232
}
33-
34-
fun <E, T : MutableList<E>> T.clearAndAdd(element: E) {
35-
this.clear()
36-
this.add(element)
37-
}
38-
39-
fun <E, T : MutableList<E>> T.clearAndAdd(vararg elements: E) {
40-
this.clear()
41-
this.addAll(elements)
42-
}

src/main/kotlin/ru/octol1ttle/flightassistant/impl/computer/autoflight/AutoFlightComputer.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class AutoFlightComputer(computers: ComputerView) : Computer(computers), FlightC
4747
HeadingControllerRegistrationCallback.EVENT.register { it.accept(this) }
4848
RollControllerRegistrationCallback.EVENT.register { it.accept(this) }
4949
ThrustChangeCallback.EVENT.register(ThrustChangeCallback { _, _, input ->
50-
if (input == null && autoThrustAlert) {
51-
autoThrustAlert = false
50+
if (input == null) {
51+
setAutoThrust(false, alert = false)
5252
}
5353
})
5454
EntityTurnEvents.X_ROT.register(EntityTurnEvents.EntityTurn { pitchDelta, output ->

src/main/kotlin/ru/octol1ttle/flightassistant/impl/computer/autoflight/base/ThrustComputer.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,5 @@ class ThrustComputer(computers: ComputerView) : Computer(computers) {
119119

120120
companion object {
121121
val ID: ResourceLocation = FlightAssistant.id("thrust")
122-
const val TOGA_THRESHOLD: Float = 0.99f // TODO: just hardcode it to 1.0f bruh
123122
}
124123
}

src/main/kotlin/ru/octol1ttle/flightassistant/impl/display/AutomationModesDisplay.kt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import ru.octol1ttle.flightassistant.api.display.Display
1414
import ru.octol1ttle.flightassistant.api.display.HudFrame
1515
import ru.octol1ttle.flightassistant.api.util.FATickCounter
1616
import ru.octol1ttle.flightassistant.api.util.extensions.*
17-
import ru.octol1ttle.flightassistant.api.util.furtherFromZero
1817
import ru.octol1ttle.flightassistant.config.FAConfig
19-
import ru.octol1ttle.flightassistant.impl.computer.autoflight.base.ThrustComputer.Companion.TOGA_THRESHOLD
2018

2119
class AutomationModesDisplay(computers: ComputerView) : Display(computers) {
2220
private val thrustDisplay: ModeDisplay = ModeDisplay(1)
@@ -51,12 +49,11 @@ class AutomationModesDisplay(computers: ComputerView) : Display(computers) {
5149
return
5250
}
5351

54-
val thrustValueText: MutableComponent = Component.literal(furtherFromZero(computers.thrust.current * 100).toString() + "%").setColor(primaryColor)
5552
if (computers.thrust.thrustLocked) {
5653
thrustDisplay.render(
5754
guiGraphics,
58-
if (computers.thrust.current > TOGA_THRESHOLD) Component.translatable("mode.flightassistant.thrust.locked_toga").setColor(primaryColor)
59-
else Component.translatable("mode.flightassistant.thrust.locked", thrustValueText).setColor(primaryColor),
55+
if (computers.thrust.current == 1.0f) Component.translatable("mode.flightassistant.thrust.locked_toga").setColor(primaryColor)
56+
else Component.translatable("mode.flightassistant.thrust.locked").setColor(primaryColor),
6057
false,
6158
if (FATickCounter.totalTicks % 20 >= 10) cautionColor else emptyColor
6259
)
@@ -67,10 +64,9 @@ class AutomationModesDisplay(computers: ComputerView) : Display(computers) {
6764
if (computers.thrust.current != 0.0f) {
6865
thrustDisplay.render(
6966
guiGraphics,
70-
if (computers.thrust.current > TOGA_THRESHOLD) Component.translatable("mode.flightassistant.thrust.manual_toga").setColor(secondaryColor)
71-
else Component.translatable("mode.flightassistant.thrust.manual", thrustValueText),
72-
computers.thrust.current == 0.0f || computers.thrust.current > TOGA_THRESHOLD,
73-
if (thrustUnusable) cautionColor else null
67+
if (computers.thrust.current == 1.0f) Component.translatable("mode.flightassistant.thrust.manual_toga").setColor(secondaryColor)
68+
else Component.translatable("mode.flightassistant.thrust.manual"),
69+
false, if (thrustUnusable) cautionColor else secondaryColor
7470
)
7571
return
7672
}

0 commit comments

Comments
 (0)