-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Octol1ttle <[email protected]>
- Loading branch information
1 parent
6207680
commit bbf2c5a
Showing
9 changed files
with
83 additions
and
9 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
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
57 changes: 57 additions & 0 deletions
57
src/main/java/net/torocraft/flighthud/computers/VoidDamageLevelComputer.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,57 @@ | ||
package net.torocraft.flighthud.computers; | ||
|
||
import net.torocraft.flighthud.indicators.PitchIndicator; | ||
|
||
public class VoidDamageLevelComputer { | ||
public static final int STATUS_REACHED_DAMAGE_LEVEL = 2; | ||
public static final int STATUS_APPROACHING_DAMAGE_LEVEL = 1; | ||
public static final int STATUS_ALTITUDE_SAFE = -1; | ||
public static final int STATUS_NOT_ABOVE_VOID = -2; | ||
public static final int STATUS_PLAYER_INVULNERABLE = -3; | ||
private static final int OPTIMUM_ALTITUDE_PRESERVATION_PITCH = 10; | ||
|
||
private final FlightComputer computer; | ||
public int status; | ||
public float minimumSafePitch; | ||
|
||
public VoidDamageLevelComputer(FlightComputer computer) { | ||
this.computer = computer; | ||
} | ||
|
||
public void tick() { | ||
status = computeStatus(); | ||
minimumSafePitch = computeMinimumSafePitch(); | ||
} | ||
|
||
private int computeStatus() { | ||
if (computer.player.isInvulnerableTo(computer.player.getDamageSources().outOfWorld())) { | ||
return STATUS_PLAYER_INVULNERABLE; | ||
} | ||
|
||
if (computer.groundLevel != computer.voidLevel) { | ||
return STATUS_NOT_ABOVE_VOID; | ||
} | ||
|
||
if (computer.altitude - computer.voidLevel >= 8) { | ||
return STATUS_ALTITUDE_SAFE; | ||
} | ||
|
||
if (computer.altitude >= computer.voidLevel) { | ||
return STATUS_APPROACHING_DAMAGE_LEVEL; | ||
} | ||
|
||
// TODO: TOGA LK | ||
return STATUS_REACHED_DAMAGE_LEVEL; | ||
} | ||
|
||
private float computeMinimumSafePitch() { | ||
if (status <= STATUS_NOT_ABOVE_VOID) { | ||
return -90.0f; | ||
} | ||
if (computer.altitude - computer.voidLevel < 20) { | ||
return Math.min(OPTIMUM_ALTITUDE_PRESERVATION_PITCH, computer.stall.maximumSafePitch); | ||
} | ||
|
||
return PitchIndicator.DANGEROUS_DOWN_PITCH + 10; | ||
} | ||
} |
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