Skip to content

Commit

Permalink
oh yes, its all coming together
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai committed Sep 16, 2024
1 parent bd7ff7d commit 895c6b4
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ public void shuffleTarget(Tardis tardis) {

@Override
public void init(Tardis tardis) {
shuffleTarget(tardis);
tardis.setSparksQueued(5);
super.init(tardis);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public abstract class InterceptState implements FlightState, RespondsToFlyLever, RespondsToNudging {
public static final int PHASES = 6;
public static final int MAX_X_OFFSET = 3;
public static final int MAX_X_OFFSET = 4;
public static final int MAX_Y_OFFSET = 2;

protected final UUID otherTardis;
Expand Down Expand Up @@ -134,8 +134,8 @@ public int getPhasesComplete() {
return phasesComplete;
}

public Optional<BeingInterceptedState> getLinkedState(Tardis tardis) {
return tardis.getHolder().getTardis(otherTardis).flatMap(t -> t.getState(BeingInterceptedState.class));
public Optional<InterceptState> getLinkedState(Tardis tardis) {
return tardis.getHolder().getTardis(otherTardis).flatMap(t -> t.getState(InterceptState.class));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dev.enjarai.minitardis.component.TardisControl;
import dev.enjarai.minitardis.component.flight.DriftingState;
import dev.enjarai.minitardis.component.flight.FlyingState;
import dev.enjarai.minitardis.component.flight.InterceptState;
import dev.enjarai.minitardis.component.flight.RefuelingState;
import dev.enjarai.minitardis.component.screen.canvas.CanvasColors;
import dev.enjarai.minitardis.component.screen.canvas.patbox.CanvasImage;
Expand All @@ -22,7 +23,7 @@
public class StatusApp implements ScreenApp {
public static final Codec<StatusApp> CODEC = Codec.unit(StatusApp::new);

private Random etaRandom = new LocalRandom(0);
private final Random etaRandom = new LocalRandom(0);

@Override
public AppView getView(TardisControl controls) {
Expand Down Expand Up @@ -101,13 +102,31 @@ public void draw(ScreenBlockEntity blockEntity, DrawableCanvas canvas) {
var stutterOffsetFuel = isSolid || (state instanceof RefuelingState && tardis.getFuel() < 1000) ? 0 : random.nextBetween(-1, 1);
drawVerticalBar(canvas, tardis.getFuel() * 480 / 10000 + stutterOffsetFuel, 72, 16, TardisCanvasUtils.getSprite("vertical_bar_blue"), "ART");

var conduitsUnlocked = controls.areEnergyConduitsUnlocked();
canvas.draw(24, 48, conduitsUnlocked ? TardisCanvasUtils.getSprite("energy_conduits_active") : TardisCanvasUtils.getSprite("energy_conduits_inactive"));
DefaultFonts.VANILLA.drawText(canvas, "CND", 24 + 7, 80, 8, CanvasColors.WHITE);
tardis.getState(InterceptState.class).ifPresentOrElse(interceptState -> {
canvas.draw(0, 16, TardisCanvasUtils.getSprite("intercept_radar"));

var targetX = interceptState.getTargetX();
var targetY = interceptState.getTargetY();
var currentX = interceptState.getOffsetX();
var currentY = interceptState.getOffsetY();
canvas.draw(35 + targetX * 6, 16 + 23 + targetY * 6, TardisCanvasUtils.getSprite("intercept_target"));
canvas.draw(35 + currentX * 6, 16 + 23 + currentY * 6, TardisCanvasUtils.getSprite("intercept_current"));

int phase = interceptState.getPhasesComplete();
int otherPhase = interceptState.getLinkedState(tardis).map(InterceptState::getPhasesComplete).orElse(0);
for (int i = 0; i < InterceptState.PHASES; i++) {
canvas.draw(8 + i * 8, 68, TardisCanvasUtils.getSprite(i < phase ? "intercept_phase_complete" : "intercept_phase"));
canvas.draw(8 + i * 8, 76, TardisCanvasUtils.getSprite(i < otherPhase ? "intercept_phase_other_complete" : "intercept_phase_other"));
}
}, () -> {
var conduitsUnlocked = controls.areEnergyConduitsUnlocked();
canvas.draw(24, 48, conduitsUnlocked ? TardisCanvasUtils.getSprite("energy_conduits_active") : TardisCanvasUtils.getSprite("energy_conduits_inactive"));
DefaultFonts.VANILLA.drawText(canvas, "CND", 24 + 7, 80, 8, CanvasColors.WHITE);

var destinationLocked = controls.isDestinationLocked();
canvas.draw(0, 48, destinationLocked ? TardisCanvasUtils.getSprite("lock_icon_locked") : TardisCanvasUtils.getSprite("lock_icon_unlocked"));
DefaultFonts.VANILLA.drawText(canvas, "LCK", 7, 80, 8, CanvasColors.WHITE);
var destinationLocked = controls.isDestinationLocked();
canvas.draw(0, 48, destinationLocked ? TardisCanvasUtils.getSprite("lock_icon_locked") : TardisCanvasUtils.getSprite("lock_icon_unlocked"));
DefaultFonts.VANILLA.drawText(canvas, "LCK", 7, 80, 8, CanvasColors.WHITE);
});
}

@Override
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 895c6b4

Please sign in to comment.