-
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: begin work on custom thrust handlers
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
- Loading branch information
1 parent
d451d4d
commit c4ec750
Showing
29 changed files
with
259 additions
and
78 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
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
27 changes: 27 additions & 0 deletions
27
...ain/java/ru/octol1ttle/flightassistant/compatibility/doabarrelroll/DaBRThrustHandler.java
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,27 @@ | ||
package ru.octol1ttle.flightassistant.compatibility.doabarrelroll; | ||
|
||
import nl.enjarai.doabarrelroll.api.event.ThrustEvents; | ||
import ru.octol1ttle.flightassistant.computers.api.IThrustHandler; | ||
import ru.octol1ttle.flightassistant.computers.impl.TimeComputer; | ||
import ru.octol1ttle.flightassistant.computers.impl.autoflight.AutoFlightComputer; | ||
import ru.octol1ttle.flightassistant.computers.impl.autoflight.ThrustController; | ||
import ru.octol1ttle.flightassistant.registries.ComputerRegistry; | ||
|
||
public class DaBRThrustHandler implements IThrustHandler { | ||
private final AutoFlightComputer autoflight = ComputerRegistry.resolve(AutoFlightComputer.class); | ||
private final ThrustController thrust = ComputerRegistry.resolve(ThrustController.class); | ||
private final TimeComputer time = ComputerRegistry.resolve(TimeComputer.class); | ||
|
||
public DaBRThrustHandler() { | ||
ThrustEvents.MODIFY_THRUST_INPUT.register(v -> { | ||
if (Math.abs(v) > 0.001f) { | ||
autoflight.disconnectAutoFirework(true); | ||
} | ||
return thrust.targetThrust += (float) (v * time.deltaTime * 0.5f); | ||
}); | ||
} | ||
|
||
@Override | ||
public void reset() { | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
src/main/java/ru/octol1ttle/flightassistant/computers/api/IThrustController.java
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,10 @@ | ||
package ru.octol1ttle.flightassistant.computers.api; | ||
|
||
public interface IThrustController extends IComputer { | ||
/** | ||
* Gets the target thrust that this controller wants | ||
* | ||
* @return a {@link ThrustControlInput} with {@link ThrustControlInput#target()} being the target thrust | ||
*/ | ||
ThrustControlInput getThrustInput(); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/ru/octol1ttle/flightassistant/computers/api/IThrustHandler.java
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,11 @@ | ||
package ru.octol1ttle.flightassistant.computers.api; | ||
|
||
import ru.octol1ttle.flightassistant.computers.impl.autoflight.ThrustController; | ||
|
||
/** | ||
* Implementing classes should inject ThrustController and use {@link ThrustController#currentThrust} and {@link ThrustController#targetThrust} themselves as needed. | ||
* Implementing this interface is required to resolve any conflicts between multiple thrust handlers. | ||
* In case of multiple thrust handlers being present, only the first one registered | ||
*/ | ||
public interface IThrustHandler extends IComputer { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/ru/octol1ttle/flightassistant/computers/api/ThrustControlInput.java
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,4 @@ | ||
package ru.octol1ttle.flightassistant.computers.api; | ||
|
||
public record ThrustControlInput(float target, float deltaTimeMultiplier, InputPriority priority) { | ||
} |
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.