Skip to content

Commit

Permalink
things
Browse files Browse the repository at this point in the history
Signed-off-by: Octol1ttle <[email protected]>
  • Loading branch information
Octol1ttle committed Aug 11, 2023
1 parent f79a1ca commit 4c2dea7
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 26 deletions.
7 changes: 4 additions & 3 deletions src/main/java/net/torocraft/flighthud/AutoFlightManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static net.torocraft.flighthud.FlightSafetyMonitor.lastFireworkActivationTimeMs;
import static net.torocraft.flighthud.FlightSafetyMonitor.maximumSafePitch;
import static net.torocraft.flighthud.FlightSafetyMonitor.secondsUntilTerrainImpact;
import static net.torocraft.flighthud.FlightSafetyMonitor.thrustLocked;
import static net.torocraft.flighthud.FlightSafetyMonitor.thrustSet;
import static net.torocraft.flighthud.FlightSafetyMonitor.usableFireworkHand;
import static net.torocraft.flighthud.HudComponent.CONFIG;
Expand Down Expand Up @@ -48,8 +49,8 @@ public static void update(MinecraftClient mc, FlightComputer computer) {
boolean approachingDestination = distanceToTarget != null && distanceToTarget < Math.max(40, computer.velocityPerSecond.horizontalLength());

if (computer.speed > 30) thrustSet = true;
if (autoThrustEnabled && usableFireworkHand != null) {
if (gpwsLampColor == CONFIG.color && computer.velocityPerSecond.horizontalLength() > 0.01 && computer.pitch > (autoPilotEnabled ? 0 : 10) && !approachingDestination) {
else if (autoThrustEnabled && usableFireworkHand != null) {
if (!thrustLocked && gpwsLampColor == CONFIG.color && computer.velocityPerSecond.horizontalLength() > 0.01 && computer.pitch > (autoPilotEnabled ? 0 : 10) && !approachingDestination) {
if (thrustSet && (computer.speed < 28 || computer.velocityPerSecond.y < -8)) {
mc.interactionManager.interactItem(mc.player, usableFireworkHand);
lastFireworkActivationTimeMs = lastUpdateTimeMs;
Expand Down Expand Up @@ -91,7 +92,7 @@ public static void update(MinecraftClient mc, FlightComputer computer) {

changeLookDirection(mc.player, targetPitch != null ? (targetPitch + computer.pitch) * deltaTime : 0.0f,
deltaHeading * deltaTime * 1.25f);
statusString += "".equals(statusString) ? "AP" : " | AP";
statusString += "".equals(statusString) ? "A/P" : " | A/P";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public boolean shouldActivate() {

@Override
public int drawText(MinecraftClient mc, DrawContext context, float x, float y, boolean highlight) {
int i = drawCaution(mc, context, x, y, highlight, "AUTO FLT A/THR LIMITED");
int i = drawCaution(mc, context, x, y, highlight, "AUTO THRUST LIMITED");
if (FlightSafetyMonitor.fireworkCount > 0)
i += HudComponent.drawFont(mc, context, " -FRWKS: SELECT", x, y + 9, CONFIG.adviceColor);
return i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ public boolean shouldActivate() {
@Override
public int drawText(MinecraftClient mc, DrawContext context, float x, float y, boolean highlight) {
int i = drawWarning(mc, context, x, y, highlight, "FRWK ACTIVATION FAIL");
if (AutoFlightManager.autoPilotEnabled || AutoFlightManager.flightDirectorsEnabled)
i += HudComponent.drawFont(mc, context, " -AP+FD: OFF", x, y += 9, CONFIG.adviceColor);
if (AutoFlightManager.flightDirectorsEnabled)
i += HudComponent.drawFont(mc, context, " -FD: OFF", x, y += 9, CONFIG.adviceColor);
if (AutoFlightManager.autoThrustEnabled)
i += HudComponent.drawFont(mc, context, " -ATHR: OFF", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " SPD MAY BE UNREL", x, y + 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " -A/THR: OFF", x, y += 9, CONFIG.adviceColor);
if (AutoFlightManager.autoPilotEnabled)
i += HudComponent.drawFont(mc, context, " -A/P: OFF", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " -PITCH: MAX SAFE UP", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " -FRWKS: DO NOT USE", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " SPD MAY BE UNRELIABLE", x, y + 9, CONFIG.adviceColor);
return i;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.torocraft.flighthud.FlightSafetyMonitor;
import net.torocraft.flighthud.HudComponent;

import static net.torocraft.flighthud.HudComponent.CONFIG;

public class FlightProtectionsOffAlert extends Alert {
@Override
Expand All @@ -12,6 +15,11 @@ public boolean shouldActivate() {

@Override
public int drawText(MinecraftClient mc, DrawContext context, float x, float y, boolean highlight) {
return drawCaution(mc, context, x, y, highlight, "FLIGHT PROT OFF");
int i = drawCaution(mc, context, x, y, highlight, "FLIGHT PROTECTIONS OFF");
i += HudComponent.drawFont(mc, context, " MAX PITCH: 40* UP", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " MIN V/S: -8 BPS", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " -FRWKS: CONFIRM SAFE", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " MANEUVER WITH CARE", x, y + 9, CONFIG.adviceColor);
return i;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.torocraft.flighthud.HudComponent;

import static net.torocraft.flighthud.FlightHud.CONFIG_SETTINGS;
import static net.torocraft.flighthud.HudComponent.CONFIG;

public class GPWSOffAlert extends Alert {
@Override
Expand All @@ -13,6 +15,11 @@ public boolean shouldActivate() {

@Override
public int drawText(MinecraftClient mc, DrawContext context, float x, float y, boolean highlight) {
return drawCaution(mc, context, x, y, highlight, "GPWS OFF");
int i = drawCaution(mc, context, x, y, highlight, "GPWS OFF");
i += HudComponent.drawFont(mc, context, " BELOW 320M", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " -A/P: DO NOT USE", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " BELOW 320M", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " -A/THR: DO NOT USE", x, y + 9, CONFIG.adviceColor);
return i;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.torocraft.flighthud.AutoFlightManager;
import net.torocraft.flighthud.FlightSafetyMonitor;
import net.torocraft.flighthud.HudComponent;

import static net.torocraft.flighthud.HudComponent.CONFIG;

public class LowFireworksAlert extends Alert {
@Override
Expand All @@ -12,6 +16,10 @@ public boolean shouldActivate() {

@Override
public int drawText(MinecraftClient mc, DrawContext context, float x, float y, boolean highlight) {
return drawCaution(mc, context, x, y, highlight, "FWOB BELOW 24");
int i = drawCaution(mc, context, x, y, highlight, "FRWK CNT BELOW 24");
if (AutoFlightManager.autoThrustEnabled)
i += HudComponent.drawFont(mc, context, " -A/THR: OFF", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " -CLIMB: INITIATE", x, y + 9, CONFIG.adviceColor);
return i;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ public boolean shouldActivate() {

@Override
public int drawText(MinecraftClient mc, DrawContext context, float x, float y, boolean highlight) {
int i = drawWarning(mc, context, x, y, highlight, "NO FRWKS ON BOARD");
int i = drawWarning(mc, context, x, y, highlight, "FRWK CNT ZERO");
if (AutoFlightManager.autoThrustEnabled)
i += HudComponent.drawFont(mc, context, " -A/THR: OFF", x, y += 9, CONFIG.adviceColor);
if (AutoFlightManager.targetAltitude != null)
i += HudComponent.drawFont(mc, context, " -AP ALT: RESET", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " GLDG DIST: 100 BLKS/10 GND ALT", x, y + 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " -A/P ALT: RESET", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " GLDG DIST:", x, y += 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, " 100 BLKS/10 M", x, y + 9, CONFIG.adviceColor);
return i;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ public boolean shouldActivate() {
@Override
public int drawText(MinecraftClient mc, DrawContext context, float x, float y, boolean highlight) {
int i = drawCaution(mc, context, x, y, highlight, "THRUST LOCKED");
if (!CONFIG_SETTINGS.gpws || !AutoFlightManager.autoPilotEnabled)
i += HudComponent.drawFont(mc, context, "-GPWS+AP: ON", x, y += 9, CONFIG.adviceColor);
if (!CONFIG_SETTINGS.gpws)
i += HudComponent.drawFont(mc, context, "-GPWS: ON", x, y += 9, CONFIG.adviceColor);
if (!AutoFlightManager.autoPilotEnabled)
i += HudComponent.drawFont(mc, context, "-A/P: ON", x, y += 9, CONFIG.adviceColor);
if (!AutoFlightManager.autoThrustEnabled) {
i += HudComponent.drawFont(mc, context, "-ATHR: ON THEN OFF", x, y + 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, "-A/THR: ON THEN OFF", x, y + 9, CONFIG.adviceColor);
return i;
}
i += HudComponent.drawFont(mc, context, "-ATHR: OFF", x, y + 9, CONFIG.adviceColor);
i += HudComponent.drawFont(mc, context, "-A/THR: OFF", x, y + 9, CONFIG.adviceColor);
return i;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public void render(DrawContext context, MinecraftClient mc) {
y += 9 * alert.drawText(mc, context, x, y, highlight);
}

int fwobLampColor = FlightSafetyMonitor.fireworkCount > 0
? (FlightSafetyMonitor.fireworkCount < 24 ? CONFIG.amberColor : CONFIG.color)
: CONFIG.alertColor;
drawRightAlignedFont(mc, context, "FRWK CNT: " + FlightSafetyMonitor.fireworkCount, xRight, yRight += 9, fwobLampColor);
// Right-side ECAM
if (AutoFlightManager.flightDirectorsEnabled) {
drawRightAlignedFont(mc, context, "FD", xRight, yRight += 9, CONFIG.color);
Expand All @@ -108,7 +112,7 @@ public void render(DrawContext context, MinecraftClient mc) {
}
}
if (AutoFlightManager.distanceToTarget != null) {
drawRightAlignedFont(mc, context, String.format("DIST: %.1f", AutoFlightManager.distanceToTarget), xRight, yRight + 9, CONFIG.color);
drawRightAlignedFont(mc, context, String.format("DIST: %.0f", AutoFlightManager.distanceToTarget), xRight, yRight + 9, CONFIG.color);
}
drawCenteredFont(mc, context, AutoFlightManager.statusString, dim.wScreen, dim.tFrame + 15, CONFIG.color);

Expand All @@ -120,7 +124,7 @@ public void render(DrawContext context, MinecraftClient mc) {
lastAutopilotState = AutoFlightManager.autoPilotEnabled;

if (FlightSafetyMonitor.isStalling && CONFIG_SETTINGS.stickShaker && computer.velocityPerSecond.y <= -10) {
playRepeating(mc, STICK_SHAKER, 0.75f);
playStickShaker(mc);
drawCenteredWarning(mc, context, dim.wScreen, dim.hScreen / 2 + 10, highlight, "STALL");
} else stopEvent(mc, STICK_SHAKER);

Expand All @@ -139,8 +143,8 @@ public void drawCenteredWarning(MinecraftClient mc, DrawContext context, float w
float x = (width - mc.textRenderer.getWidth(text)) / 2;
if (highlight) {
HudComponent.drawUnbatched(drawContext -> {
HudComponent.drawTextHighlight(mc.textRenderer, context, x, y, text, CONFIG.alertColor);
HudComponent.drawCenteredFont(mc, context, text, width, y, CONFIG.white);
HudComponent.drawTextHighlight(mc.textRenderer, drawContext, x, y, text, CONFIG.alertColor);
HudComponent.drawCenteredFont(mc, drawContext, text, width, y, CONFIG.white);
}, context);
return;
}
Expand All @@ -164,10 +168,10 @@ private void playOnce(MinecraftClient mc, SoundEvent event, float volume, boolea
}
}

private void playRepeating(MinecraftClient mc, SoundEvent event, float volume) {
if (!activeEvents.contains(event)) {
mc.getSoundManager().play(new AlertSoundInstance(event, volume, mc.player, true));
activeEvents.add(event);
private void playStickShaker(MinecraftClient mc) {
if (!activeEvents.contains(FlightStatusIndicator.STICK_SHAKER)) {
mc.getSoundManager().play(new AlertSoundInstance(FlightStatusIndicator.STICK_SHAKER, (float) 0.75, mc.player, true));
activeEvents.add(FlightStatusIndicator.STICK_SHAKER);
}
}

Expand Down

0 comments on commit 4c2dea7

Please sign in to comment.