Skip to content

Commit

Permalink
Add CARGO_FILL to Readouts and Stats
Browse files Browse the repository at this point in the history
  • Loading branch information
cam72cam committed Dec 11, 2023
1 parent 94c1f19 commit e18d48a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public enum Readouts {
FRONT_LOCOMOTIVE_ANGLE,
REAR_LOCOMOTIVE_ANGLE,
CYLINDER_DRAIN,
CARGO_FILL
;

public float getValue(EntityRollingStock stock) {
Expand Down Expand Up @@ -98,6 +99,8 @@ public float getValue(EntityRollingStock stock, float lever) {
return rear instanceof LocomotiveModel ? yawToPercent(((LocomotiveModel<?, ?>)rear).getRearLocomotiveYaw((EntityMoveableRollingStock) stock), 90) : 0.5f;
case CYLINDER_DRAIN:
return stock instanceof LocomotiveSteam && ((LocomotiveSteam) stock).cylinderDrainsEnabled() ? 1 : 0;
case CARGO_FILL:
return stock instanceof Freight ? ((Freight) stock).getPercentCargoFull() / 100f : 0;
}
return 0;
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/cam72cam/immersiverailroading/gui/overlay/Stat.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public enum Stat {
BRAKE_PRESSURE,
MAX_BRAKE_PRESSURE,
UNITS_BRAKE_PRESSURE,
CARGO_FILL,
MAX_CARGO_FILL,
UNITS_CARGO_FILL,
;

public String getValue(EntityRollingStock stock) {
Expand Down Expand Up @@ -107,6 +110,15 @@ public String getValue(EntityRollingStock stock) {
return "100";
case UNITS_BRAKE_PRESSURE:
return "%";
case CARGO_FILL:
if (stock instanceof Freight) {
return String.format("%s", ((Freight) stock).getPercentCargoFull());
}
return "";
case MAX_CARGO_FILL:
return "100";
case UNITS_CARGO_FILL:
return "%";
}
return "";
}
Expand Down

0 comments on commit e18d48a

Please sign in to comment.