Skip to content

Commit

Permalink
"Move field assignment to declaration"
Browse files Browse the repository at this point in the history
  • Loading branch information
Octol1ttle committed Apr 7, 2024
1 parent 612ce7f commit 83ecbda
Show file tree
Hide file tree
Showing 28 changed files with 47 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
import ru.octol1ttle.flightassistant.registries.ComputerRegistry;

public class AutoFireworkOffAlert extends BaseAlert implements IECAMAlert {
private final AutoFlightComputer autoflight;

public AutoFireworkOffAlert() {
this.autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);
}
private final AutoFlightComputer autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);

@Override
public boolean isTriggered() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
import ru.octol1ttle.flightassistant.registries.ComputerRegistry;

public class AutopilotOffAlert extends BaseAlert implements IECAMAlert {
private final AutoFlightComputer autoflight;

public AutopilotOffAlert() {
this.autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);
}
private final AutoFlightComputer autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);

@Override
public boolean isTriggered() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@


public class FireworkNoResponseAlert extends BaseAlert implements IECAMAlert {

private final FireworkController firework;

public FireworkNoResponseAlert() {
this.firework = ComputerRegistry.resolve(FireworkController.class);
}
private final FireworkController firework = ComputerRegistry.resolve(FireworkController.class);

@Override
public boolean isTriggered() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@


public class FireworkUnsafeAlert extends BaseAlert implements IECAMAlert {
private final AirDataComputer data;
private final FireworkController firework;

public FireworkUnsafeAlert() {
this.data = ComputerRegistry.resolve(AirDataComputer.class);
this.firework = ComputerRegistry.resolve(FireworkController.class);
}
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);
private final FireworkController firework = ComputerRegistry.resolve(FireworkController.class);

@Override
public boolean isTriggered() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
import ru.octol1ttle.flightassistant.registries.ComputerRegistry;

public class ApproachingVoidDamageLevelAlert extends BaseAlert implements IECAMAlert {
private final VoidLevelComputer voidLevel;

public ApproachingVoidDamageLevelAlert() {
this.voidLevel = ComputerRegistry.resolve(VoidLevelComputer.class);
}
private final VoidLevelComputer voidLevel = ComputerRegistry.resolve(VoidLevelComputer.class);

@Override
public boolean isTriggered() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@
import ru.octol1ttle.flightassistant.registries.ComputerRegistry;

public class MinimumsAlert extends BaseAlert implements IECAMAlert {
private final FlightPlanner plan;
private final FlightPlanner plan = ComputerRegistry.resolve(FlightPlanner.class);
private boolean triggered = false;

public MinimumsAlert() {
this.plan = ComputerRegistry.resolve(FlightPlanner.class);
}

@Override
public boolean isTriggered() {
if (plan.getMinimums(0) == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
import ru.octol1ttle.flightassistant.registries.ComputerRegistry;

public class UnloadedChunkAlert extends BaseAlert implements IECAMAlert {
private final ChunkStatusComputer chunkStatus;

public UnloadedChunkAlert() {
this.chunkStatus = ComputerRegistry.resolve(ChunkStatusComputer.class);
}
private final ChunkStatusComputer chunkStatus = ComputerRegistry.resolve(ChunkStatusComputer.class);

@Override
public boolean isTriggered() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@
public class ExcessiveDescentAlert extends BaseAlert implements ICenteredAlert {
private static final float SINK_RATE_THRESHOLD = 7.5f;
private static final float PULL_UP_THRESHOLD = 5.0f;
private final AirDataComputer data;
private final GPWSComputer gpws;

public ExcessiveDescentAlert() {
this.data = ComputerRegistry.resolve(AirDataComputer.class);
this.gpws = ComputerRegistry.resolve(GPWSComputer.class);
}
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);
private final GPWSComputer gpws = ComputerRegistry.resolve(GPWSComputer.class);

@Override
public boolean isTriggered() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@ public class ExcessiveTerrainClosureAlert extends BaseAlert implements ICentered

private static final float PULL_UP_THRESHOLD = 5.0f;
private static final float DELAY_ALERT_FOR = 0.5f;
private final GPWSComputer gpws;
private final TimeComputer time;
private final GPWSComputer gpws = ComputerRegistry.resolve(GPWSComputer.class);
private final TimeComputer time = ComputerRegistry.resolve(TimeComputer.class);
private boolean delayFull = false;
private float delay = 0.0f;

public ExcessiveTerrainClosureAlert() {
this.gpws = ComputerRegistry.resolve(GPWSComputer.class);
this.time = ComputerRegistry.resolve(TimeComputer.class);
}

@Override
public boolean isTriggered() {
if (gpws.descentImpactTime >= 0.0f) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
import ru.octol1ttle.flightassistant.registries.ComputerRegistry;

public class UnsafeTerrainClearanceAlert extends BaseAlert implements ICenteredAlert {
private final GPWSComputer gpws;
private final FlightPlanner plan;

public UnsafeTerrainClearanceAlert() {
this.gpws = ComputerRegistry.resolve(GPWSComputer.class);
this.plan = ComputerRegistry.resolve(FlightPlanner.class);
}
private final GPWSComputer gpws = ComputerRegistry.resolve(GPWSComputer.class);
private final FlightPlanner plan = ComputerRegistry.resolve(FlightPlanner.class);

@Override
public boolean isTriggered() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
import ru.octol1ttle.flightassistant.registries.ComputerRegistry;

public class ElytraHealthLowAlert extends BaseAlert implements IECAMAlert {
private final AirDataComputer data;

public ElytraHealthLowAlert() {
this.data = ComputerRegistry.resolve(AirDataComputer.class);
}
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);

@Override
public boolean isTriggered() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@


public class StallAlert extends BaseAlert implements ICenteredAlert {
private final StallComputer stall;

public StallAlert() {
this.stall = ComputerRegistry.resolve(StallComputer.class);
}
private final StallComputer stall = ComputerRegistry.resolve(StallComputer.class);

@Override
public boolean isTriggered() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
import ru.octol1ttle.flightassistant.registries.ComputerRegistry;

public class AlertController implements ITickableComputer {
public final List<BaseAlert> activeAlerts;
private final AirDataComputer airData;
public final List<BaseAlert> activeAlerts = new ArrayList<>();
private final AirDataComputer airData = ComputerRegistry.resolve(AirDataComputer.class);
private final SoundManager manager;

public AlertController(SoundManager manager) {
this.airData = ComputerRegistry.resolve(AirDataComputer.class);
this.manager = manager;
// TODO: ECAM actions
AlertRegistry.register(new StallAlert());
Expand All @@ -50,8 +49,6 @@ public AlertController(SoundManager manager) {
AlertRegistry.register(new ElytraHealthLowAlert());
AlertRegistry.register(new FireworkUnsafeAlert());
AlertRegistry.register(new FireworkNoResponseAlert());

activeAlerts = new ArrayList<>();
}

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

public class AlertDisplay implements IHudDisplay {
private final Dimensions dim;
private final AlertController alert;
private final TimeComputer time;
private final AlertController alert = ComputerRegistry.resolve(AlertController.class);
private final TimeComputer time = ComputerRegistry.resolve(TimeComputer.class);

public AlertDisplay(Dimensions dim) {
this.dim = dim;
this.alert = ComputerRegistry.resolve(AlertController.class);
this.time = ComputerRegistry.resolve(TimeComputer.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@

public class AltitudeDisplay implements IHudDisplay {
private final Dimensions dim;
private final AirDataComputer data;
private final AutoFlightComputer autoflight;
private final FlightPlanner plan;
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);
private final AutoFlightComputer autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);
private final FlightPlanner plan = ComputerRegistry.resolve(FlightPlanner.class);

public AltitudeDisplay(Dimensions dim) {
this.dim = dim;
this.data = ComputerRegistry.resolve(AirDataComputer.class);
this.autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);
this.plan = ComputerRegistry.resolve(FlightPlanner.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
public class AttitudeDisplay implements IHudDisplay {
public static final int DEGREES_PER_BAR = 20;
private final Dimensions dim;
private final AirDataComputer data;
private final StallComputer stall;
private final VoidLevelComputer voidLevel;
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);
private final StallComputer stall = ComputerRegistry.resolve(StallComputer.class);
private final VoidLevelComputer voidLevel = ComputerRegistry.resolve(VoidLevelComputer.class);
private final AttitudeIndicatorData pitchData = new AttitudeIndicatorData();

public AttitudeDisplay(Dimensions dim) {
this.dim = dim;
this.data = ComputerRegistry.resolve(AirDataComputer.class);
this.stall = ComputerRegistry.resolve(StallComputer.class);
this.voidLevel = ComputerRegistry.resolve(VoidLevelComputer.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
public class ElytraHealthDisplay implements IHudDisplay {

private final Dimensions dim;
private final AirDataComputer data;
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);

public ElytraHealthDisplay(Dimensions dim) {
this.dim = dim;
this.data = ComputerRegistry.resolve(AirDataComputer.class);
}

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

public class FlightDirectorsDisplay implements IHudDisplay {
private final Dimensions dim;
private final AirDataComputer data;
private final AutoFlightComputer autoflight;
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);
private final AutoFlightComputer autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);

public FlightDirectorsDisplay(Dimensions dim) {
this.dim = dim;
this.data = ComputerRegistry.resolve(AirDataComputer.class);
this.autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);
}

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

public class FlightMode {
private static final int UPDATE_FLASH_TIME = 3000;
private final TimeComputer time;
private final TimeComputer time = ComputerRegistry.resolve(TimeComputer.class);
@Nullable
private Float lastUpdateTime;
@Nullable
private Text lastText;

public FlightMode() {
this.time = ComputerRegistry.resolve(TimeComputer.class);
}

public void update(Text newText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

public class FlightModeDisplay implements IHudDisplay {
private final Dimensions dim;
private final AirDataComputer data;
private final TimeComputer time;
private final FireworkController firework;
private final AutoFlightComputer autoflight;
private final FlightPlanner plan;
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);
private final TimeComputer time = ComputerRegistry.resolve(TimeComputer.class);
private final FireworkController firework = ComputerRegistry.resolve(FireworkController.class);
private final AutoFlightComputer autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);
private final FlightPlanner plan = ComputerRegistry.resolve(FlightPlanner.class);

private final FlightMode fireworkMode;
private final FlightMode verticalMode;
Expand All @@ -32,11 +32,6 @@ public class FlightModeDisplay implements IHudDisplay {

public FlightModeDisplay(Dimensions dim) {
this.dim = dim;
this.data = ComputerRegistry.resolve(AirDataComputer.class);
this.time = ComputerRegistry.resolve(TimeComputer.class);
this.firework = ComputerRegistry.resolve(FireworkController.class);
this.autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);
this.plan = ComputerRegistry.resolve(FlightPlanner.class);

this.fireworkMode = new FlightMode();
this.verticalMode = new FlightMode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@

public class FlightPathDisplay implements IHudDisplay {
private final Dimensions dim;
private final AirDataComputer data;
private final GPWSComputer gpws;
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);
private final GPWSComputer gpws = ComputerRegistry.resolve(GPWSComputer.class);

public FlightPathDisplay(Dimensions dim) {
this.dim = dim;
this.data = ComputerRegistry.resolve(AirDataComputer.class);
this.gpws = ComputerRegistry.resolve(GPWSComputer.class);
}

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

public class GroundSpeedDisplay implements IHudDisplay {
private final Dimensions dim;
private final AirDataComputer data;
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);

public GroundSpeedDisplay(Dimensions dim) {
this.dim = dim;
this.data = ComputerRegistry.resolve(AirDataComputer.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
public class HeadingDisplay implements IHudDisplay {

private final Dimensions dim;
private final AirDataComputer data;
private final AutoFlightComputer autoflight;
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);
private final AutoFlightComputer autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);

public HeadingDisplay(Dimensions dim) {
this.dim = dim;
this.data = ComputerRegistry.resolve(AirDataComputer.class);
this.autoflight = ComputerRegistry.resolve(AutoFlightComputer.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
public class LocationDisplay implements IHudDisplay {

private final Dimensions dim;
private final AirDataComputer data;
private final AirDataComputer data = ComputerRegistry.resolve(AirDataComputer.class);

public LocationDisplay(Dimensions dim) {
this.dim = dim;
this.data = ComputerRegistry.resolve(AirDataComputer.class);
}

@Override
Expand Down
Loading

0 comments on commit 83ecbda

Please sign in to comment.