-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add roll controller & source support
Signed-off-by: Octol1ttle <[email protected]>
- Loading branch information
1 parent
d9a0b21
commit b625c91
Showing
29 changed files
with
250 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/kotlin/nl/enjarai/doabarrelroll/compat/flightassistant/DaBRRollComputer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package nl.enjarai.doabarrelroll.compat.flightassistant | ||
|
||
//? if do-a-barrel-roll { | ||
import net.minecraft.util.Identifier | ||
import nl.enjarai.doabarrelroll.DoABarrelRoll | ||
import nl.enjarai.doabarrelroll.api.RollEntity | ||
import ru.octol1ttle.flightassistant.api.autoflight.roll.RollSource | ||
import ru.octol1ttle.flightassistant.api.computer.Computer | ||
import ru.octol1ttle.flightassistant.api.computer.ComputerView | ||
import ru.octol1ttle.flightassistant.api.util.FATickCounter | ||
|
||
class DaBRRollComputer(computers: ComputerView) : Computer(computers), RollSource { | ||
override fun isActive(): Boolean { | ||
return (computers.data.player as RollEntity).`doABarrelRoll$isRolling`() | ||
} | ||
|
||
override fun getRoll(): Float { | ||
return (computers.data.player as RollEntity).`doABarrelRoll$getRoll`(FATickCounter.tickProgress) | ||
} | ||
|
||
override fun addRoll(diff: Float) { | ||
return (computers.data.player as RollEntity).`doABarrelRoll$setRoll`(getRoll() + diff) | ||
} | ||
|
||
override fun tick() { | ||
} | ||
|
||
override fun reset() { | ||
} | ||
|
||
companion object { | ||
val ID: Identifier = DoABarrelRoll.id("roll") | ||
} | ||
} | ||
|
||
//?} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/ru/octol1ttle/flightassistant/api/autoflight/FlightController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ru.octol1ttle.flightassistant.api.autoflight | ||
|
||
/** | ||
* Represents a flight controller that can provide thrust, pitch, heading or roll inputs. Implementing all methods is optional. | ||
* @see [ControlInput] | ||
*/ | ||
interface FlightController { | ||
fun getThrustInput(): ControlInput? { | ||
return null | ||
} | ||
fun getPitchInput(): ControlInput? { | ||
return null | ||
} | ||
fun getHeadingInput(): ControlInput? { | ||
return null | ||
} | ||
fun getRollInput(): ControlInput? { | ||
return null | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
src/main/kotlin/ru/octol1ttle/flightassistant/api/autoflight/heading/HeadingController.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
src/main/kotlin/ru/octol1ttle/flightassistant/api/autoflight/pitch/PitchController.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...n/ru/octol1ttle/flightassistant/api/autoflight/roll/RollControllerRegistrationCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package ru.octol1ttle.flightassistant.api.autoflight.roll | ||
|
||
import dev.architectury.event.Event | ||
import dev.architectury.event.EventFactory | ||
import java.util.function.Consumer | ||
import ru.octol1ttle.flightassistant.api.autoflight.FlightController | ||
|
||
fun interface RollControllerRegistrationCallback { | ||
/** | ||
* Called during [ru.octol1ttle.flightassistant.api.computer.Computer.invokeEvents]. | ||
* Register your custom roll controllers in this event using the provided function | ||
*/ | ||
fun register(registerFunction: Consumer<FlightController>) | ||
|
||
companion object { | ||
@JvmField | ||
val EVENT: Event<RollControllerRegistrationCallback> = EventFactory.createLoop() | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/ru/octol1ttle/flightassistant/api/autoflight/roll/RollSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package ru.octol1ttle.flightassistant.api.autoflight.roll | ||
|
||
/** | ||
* Defines a source of roll to be used by the [ru.octol1ttle.flightassistant.impl.computer.autoflight.RollComputer] | ||
*/ | ||
interface RollSource { | ||
/** | ||
* @return whether this roll source is currently active. In the event there are multiple active roll sources, none of them are used. | ||
*/ | ||
fun isActive(): Boolean | ||
|
||
fun getRoll(): Float | ||
fun addRoll(diff: Float) | ||
} |
18 changes: 18 additions & 0 deletions
18
...otlin/ru/octol1ttle/flightassistant/api/autoflight/roll/RollSourceRegistrationCallback.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ru.octol1ttle.flightassistant.api.autoflight.roll | ||
|
||
import dev.architectury.event.Event | ||
import dev.architectury.event.EventFactory | ||
import java.util.function.Consumer | ||
|
||
fun interface RollSourceRegistrationCallback { | ||
/** | ||
* Called during [ru.octol1ttle.flightassistant.api.computer.Computer.invokeEvents]. | ||
* Register your custom roll sources in this event using the provided function | ||
*/ | ||
fun register(registerFunction: Consumer<RollSource>) | ||
|
||
companion object { | ||
@JvmField | ||
val EVENT: Event<RollSourceRegistrationCallback> = EventFactory.createLoop() | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
src/main/kotlin/ru/octol1ttle/flightassistant/api/autoflight/thrust/ThrustController.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.