diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java index 3dcf978..232e4fd 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryPlugin.java @@ -307,31 +307,32 @@ public void onMenuOptionClicked(MenuOptionClicked event) } } + // Could not find a varbit to capture, so capture the menu-option directly. - // start the HeatActionStateMachine when varbit begins to update in onVarbitChanged() + // start the HeatChangerStateMachine when varbit begins to update in onVarbitChanged() if (event.getMenuOption().startsWith("Heat-preform")) { - state.heatActionStateMachine.stop(); - state.heatActionStateMachine.setup(false, true, "heats"); + state.heatChangerStateMachine.stop(); + state.heatChangerStateMachine.setup(false, true, "Heats"); } else if (event.getMenuOption().startsWith("Dunk-preform")) { - state.heatActionStateMachine.stop(); - state.heatActionStateMachine.setup(true, true, "dunks"); + state.heatChangerStateMachine.stop(); + state.heatChangerStateMachine.setup(true, true, "Dunks"); } else if (event.getMenuOption().startsWith("Cool-preform")) { - state.heatActionStateMachine.stop(); - state.heatActionStateMachine.setup(false, false, "cools"); + state.heatChangerStateMachine.stop(); + state.heatChangerStateMachine.setup(false, false, "Cools"); } else if (event.getMenuOption().startsWith("Quench-preform")) { - state.heatActionStateMachine.stop(); - state.heatActionStateMachine.setup(true, false, "quenches"); + state.heatChangerStateMachine.stop(); + state.heatChangerStateMachine.setup(true, false, "Quenches"); } - else if (!state.heatActionStateMachine.isIdle()) // canceled heating/cooling, stop the heating state-machine + else // canceled heating/cooling, stop the heating state-machine { - state.heatActionStateMachine.stop(); + state.heatChangerStateMachine.stop(); } }); @@ -395,14 +396,14 @@ public void onVarbitChanged(VarbitChanged event) // sign check: num * num > 0 == same sign if (delta != -1) { - if (state.heatActionStateMachine.getActionname() != null) + if (state.heatChangerStateMachine.getActionName() != null) { // if the state-machine is idle, start it - if (state.heatActionStateMachine.isIdle()) + if (state.heatChangerStateMachine.isIdle()) { - state.heatActionStateMachine.start(state, config, previousHeat); + state.heatChangerStateMachine.start(state, config, previousHeat); } - state.heatActionStateMachine.onTick(); + state.heatChangerStateMachine.onTick(); } if (config.debugging()) @@ -410,9 +411,9 @@ public void onVarbitChanged(VarbitChanged event) client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Heat: " + event.getValue() + "" + "Delta: " + delta + " " + - "Heating Ticks: " + state.heatActionStateMachine.heatingTicks + "" + - " Cooling Ticks: " + state.heatActionStateMachine.coolingTicks + "" + - " Remaining Ticks: " + state.heatActionStateMachine.getRemainingDuration(), ""); + "Heating Ticks: " + state.heatChangerStateMachine.heatingTicks + "" + + " Cooling Ticks: " + state.heatChangerStateMachine.coolingTicks + "" + + " Remaining Ticks: " + state.heatChangerStateMachine.getRemainingDuration(), ""); } } diff --git a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryState.java b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryState.java index 1a80774..27be191 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryState.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/EasyGiantsFoundryState.java @@ -49,7 +49,7 @@ public class EasyGiantsFoundryState private final List stages = new ArrayList<>(); private double heatRangeRatio = 0; - public final HeatActionStateMachine heatActionStateMachine = new HeatActionStateMachine(); + public final HeatChangerStateMachine heatChangerStateMachine = new HeatChangerStateMachine(); public void reset() { diff --git a/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java b/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java index d7283d7..1b7e6c9 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/FoundryOverlay3D.java @@ -5,7 +5,6 @@ import static com.toofifty.easygiantsfoundry.MouldHelper.SWORD_TYPE_1_VARBIT; import static com.toofifty.easygiantsfoundry.MouldHelper.SWORD_TYPE_2_VARBIT; import com.toofifty.easygiantsfoundry.enums.CommissionType; -import com.toofifty.easygiantsfoundry.enums.Heat; import com.toofifty.easygiantsfoundry.enums.Stage; import java.awt.Color; @@ -63,9 +62,9 @@ private FoundryOverlay3D( this.modelOutlineRenderer = modelOutlineRenderer; } - private Color getObjectColor(Stage stage, Heat heat) + private Color getToolColor() { - if (stage.getHeat() != heat) + if (state.getCurrentStage().getHeat() != state.getCurrentHeat()) { return config.toolBad(); } @@ -85,7 +84,7 @@ private Color getObjectColor(Stage stage, Heat heat) return config.toolGood(); } - private GameObject getStageObject(Stage stage) + private GameObject getStageGameObject(Stage stage) { switch (stage) { @@ -140,88 +139,114 @@ public Dimension render(Graphics2D graphics) return null; } - Stage stage = state.getCurrentStage(); - GameObject stageObject = getStageObject(stage); - if (stageObject == null || graphics == null) + if (config.drawHeatLeftOverlay()) { - return null; + drawHeatLeftInfo(graphics); + } + + if (config.drawActionLeftOverlay()) + { + drawActionLeftInfo(graphics); + } + + if (config.highlightTools()) + { + drawToolHighlight(graphics); } - drawActionOverlay(graphics, stageObject); + drawHeatChangersIfEnabled(graphics); - Heat heat = state.getCurrentHeat(); - Color color = getObjectColor(stage, heat); - // TODO Config + + return null; + } + + private void drawToolHighlight(Graphics2D graphics) + { + Color color = getToolColor(); + GameObject stageObject = getStageGameObject(state.getCurrentStage()); if (config.highlightStyle() == HighlightStyle.HIGHLIGHT_CLICKBOX) { drawObjectClickbox(graphics, stageObject, color); } else { - drawObjectOutline(graphics, stageObject, color); + drawObjectOutline(stageObject, color); } + } + + private void drawHeatChangersIfEnabled(Graphics2D graphics) + { - // !state.heatingCoolingState.isIdle() - // if the stage heat is already in range, but player still wants to do heat changes - if ((stage.getHeat() != heat || !state.heatActionStateMachine.isIdle()) && config.highlightWaterAndLava()) + if (state.heatChangerStateMachine.isCooling()) { - drawHeatChangers(graphics); + _drawHeatChangerStateMachineIfEnabled(graphics, waterfall); + return; } - // mouse hover over preview - else if (config.drawLavaWaterInfoOverlay()) + + if (state.heatChangerStateMachine.isHeating()) { - MenuEntry[] menuEntries = client.getMenuEntries(); - if (menuEntries.length != 0) - { - MenuEntry hoveredMenu = menuEntries[menuEntries.length - 1]; + _drawHeatChangerStateMachineIfEnabled(graphics, lavaPool); + return; + } - if (hoveredMenu.getIdentifier() == lavaPool.getId()) - { - drawHeatChangerPreviewOverlay(graphics, lavaPool, true); - } - else if (hoveredMenu.getIdentifier() == waterfall.getId()) - { - drawHeatChangerPreviewOverlay(graphics, waterfall, false); - } - } + if (state.heatChangerStateMachine.isPending()) + { + final boolean isLava = state.heatChangerStateMachine.actionHeating; + final GameObject gameObject = isLava ? lavaPool : waterfall; + _drawHeatChangerPreviewIfEnabled(graphics, isLava); + return; } - return null; - } + final boolean needLava = state.getHeatChangeNeeded() > 0; + final boolean needWaterfall = state.getHeatChangeNeeded() < 0; - private void drawObjectClickbox(Graphics2D graphics, GameObject stageObject, Color color) - { - Shape objectClickbox = stageObject.getClickbox(); - if (objectClickbox != null && config.highlightTools()) + if (needWaterfall) { - Point mousePosition = client.getMouseCanvasPosition(); - if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) + _drawHeatChangerPreviewIfEnabled(graphics, false); + return; + } + else if (needLava) + { + _drawHeatChangerPreviewIfEnabled(graphics, true); + return; + } + + MenuEntry[] menuEntries = client.getMenuEntries(); + if (menuEntries.length != 0) + { + MenuEntry hoveredMenu = menuEntries[menuEntries.length - 1]; + + if (hoveredMenu.getIdentifier() == lavaPool.getId()) { - graphics.setColor(color.darker()); + _drawHeatChangerPreviewIfEnabled(graphics, true); + return; } - else + + if (hoveredMenu.getIdentifier() == waterfall.getId()) { - graphics.setColor(color); + _drawHeatChangerPreviewIfEnabled(graphics, false); + return; } - graphics.draw(objectClickbox); - graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20)); - graphics.fill(objectClickbox); } - } - private void drawObjectOutline(Graphics2D graphics, GameObject stageObject, Color color) - { - Color _color = new Color(color.getRed(), color.getGreen(), color.getBlue(), config.borderAlpha()); - modelOutlineRenderer.drawOutline(stageObject, config.borderThickness(), _color, config.borderFeather()); } - private void drawHeatChangerPreviewOverlay( - Graphics2D graphics, - GameObject stageObject, - boolean isLava - ) + /** + * Private helper for drawHeatChangersIfEnabled + * An live updating solve for preview before the statemachine has started. Shows both fast and slow. + * Draws both clickbox & info, depending on plugin config. + */ + private void _drawHeatChangerPreviewIfEnabled(Graphics2D graphics, boolean isLava) { + // early exit if we're not rendering anything + if (!config.highlightWaterAndLava() && !config.drawLavaWaterInfoOverlay()) + { + return; + } + + GameObject gameObject = isLava ? lavaPool : waterfall; + HeatActionSolver.DurationResult fastResult = HeatActionSolver.solve( state.getCurrentStage(), @@ -248,119 +273,91 @@ private void drawHeatChangerPreviewOverlay( ); final int slowDuration = slowResult.getDuration(); - final String fastName = isLava ? "dunks" : "quenches"; - final String slowName = isLava ? "heats" : "cools"; - - String text; - if (config.debugging()) + if (fastDuration == 0 && slowDuration == 0) { - text = String.format("%d %s (predicted: %d) or %d %s (predicted: %d) (overshoot: %s goal-in-range: %s)", - fastDuration, fastName, fastResult.getPredictedHeat(), slowDuration, slowName, slowResult.getPredictedHeat(), slowResult.isOvershooting(), fastResult.isGoalInRange()); + return; } - else + + if (config.highlightWaterAndLava()) { - text = String.format("%d %s or %d %s ", - fastDuration, fastName, slowDuration, slowName); + drawObjectClickbox(graphics, gameObject, config.lavaWaterfallColour()); } - LocalPoint stageLoc = stageObject.getLocalLocation(); - stageLoc = new LocalPoint(stageLoc.getX(), stageLoc.getY()); - - Point pos = Perspective.getCanvasTextLocation(client, graphics, stageLoc, text, 50); - if (pos == null) + if (config.drawLavaWaterInfoOverlay()) { - return; - } + final String fastName = isLava ? "Dunks" : "Quenches"; + final String slowName = isLava ? "Heats" : "Cools"; - Color color = config.lavaWaterfallColour(); + String text; + if (config.debugging()) + { + text = String.format("%d %s (predicted: %d) or %d %s (predicted: %d) (overshoot: %s goal-in-range: %s)", + fastDuration, fastName, fastResult.getPredictedHeat(), slowDuration, slowName, slowResult.getPredictedHeat(), slowResult.isOvershooting(), fastResult.isGoalInRange()); + } + else + { + text = String.format("%d %s or %d %s ", + fastDuration, fastName, slowDuration, slowName); + } - OverlayUtil.renderTextLocation(graphics, pos, text, color); - } + LocalPoint stageLoc = gameObject.getLocalLocation(); + stageLoc = new LocalPoint(stageLoc.getX(), stageLoc.getY()); - private void drawHeatChangerOverlay(Graphics2D graphics, GameObject stageObject) - { + Point pos = Perspective.getCanvasTextLocation(client, graphics, stageLoc, text, 50); + if (pos == null) + { + return; + } - String text; - if (config.debugging()) - { - text = String.format("%d %s (overshoot: %s) [goal-in-range: %s]", - state.heatActionStateMachine.getRemainingDuration(), - state.heatActionStateMachine.getActionname(), - state.heatActionStateMachine.isOverShooting(), - state.heatActionStateMachine.isGoalInRange() - ); - } - else - { - text = String.format("%d %s", - state.heatActionStateMachine.getRemainingDuration(), - state.heatActionStateMachine.getActionname() - ); + OverlayUtil.renderTextLocation(graphics, pos, text, config.lavaWaterfallColour()); } - LocalPoint stageLoc = stageObject.getLocalLocation(); - stageLoc = new LocalPoint(stageLoc.getX(), stageLoc.getY()); - - Point pos = Perspective.getCanvasTextLocation(client, graphics, stageLoc, text, 50); - Color color = config.lavaWaterfallColour(); - - OverlayUtil.renderTextLocation(graphics, pos, text, color); } - private void drawHeatChangers(Graphics2D graphics) + /** + * Private helper for drawHeatChangersIfEnabled. + * State Machine solves once and tracks the progress over time. Only draws the ongoing action for clarity. + * Draws both clickbox & info, depending on plugin config. + * @param gameObject Lava/Waterfall gameObject + */ + private void _drawHeatChangerStateMachineIfEnabled(Graphics2D graphics, GameObject gameObject) { - int change = state.getHeatChangeNeeded(); - Shape shape = null; - - boolean isLava = change > 0; - boolean isWaterfall = change < 0; - if (isWaterfall || state.heatActionStateMachine.isCooling()) + if (config.highlightWaterAndLava()) { - shape = waterfall.getClickbox(); - } - else if (isLava || state.heatActionStateMachine.isHeating()) - { - shape = lavaPool.getClickbox(); - } - if (shape != null) - { - Point mousePosition = client.getMouseCanvasPosition(); - Color color = config.lavaWaterfallColour(); - if (shape.contains(mousePosition.getX(), mousePosition.getY())) - { - graphics.setColor(color.darker()); - } - else - { - graphics.setColor(color); - } - graphics.draw(shape); - graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20)); - graphics.fill(shape); + drawObjectClickbox(graphics, gameObject, config.lavaWaterfallColour()); } if (config.drawLavaWaterInfoOverlay()) { - if (state.heatActionStateMachine.isCooling()) - { - drawHeatChangerOverlay(graphics, waterfall); - } - else if (isWaterfall) - { - drawHeatChangerPreviewOverlay(graphics, waterfall, false); - } - if (state.heatActionStateMachine.isHeating()) + String text; + if (config.debugging()) { - drawHeatChangerOverlay(graphics, lavaPool); + text = String.format("%d %s (overshoot: %s) [goal-in-range: %s]", + state.heatChangerStateMachine.getRemainingDuration(), + state.heatChangerStateMachine.getActionName(), + state.heatChangerStateMachine.isOverShooting(), + state.heatChangerStateMachine.isGoalInRange() + ); } - else if (isLava) + else { - drawHeatChangerPreviewOverlay(graphics, lavaPool, true); + text = String.format("%d %s", + state.heatChangerStateMachine.getRemainingDuration(), + state.heatChangerStateMachine.getActionName() + ); } + + LocalPoint stageLoc = gameObject.getLocalLocation(); + stageLoc = new LocalPoint(stageLoc.getX(), stageLoc.getY()); + + Point pos = Perspective.getCanvasTextLocation(client, graphics, stageLoc, text, 50); + + OverlayUtil.renderTextLocation(graphics, pos, text, config.lavaWaterfallColour()); } } + private void drawCrucibleContent(Graphics2D graphics) { if (!config.drawCrucibleInfoOverlay()) @@ -471,7 +468,7 @@ else if (config.highlightStyle() == HighlightStyle.HIGHLIGHT_BORDER) { color = config.generalHighlight(); } - drawObjectOutline(graphics, crucible, color); + drawObjectOutline(crucible, color); } } @@ -498,7 +495,7 @@ private void drawMouldIfNotSet(Graphics2D graphics) } else if (config.highlightStyle() == HighlightStyle.HIGHLIGHT_BORDER) { - drawObjectOutline(graphics, mouldJig, config.generalHighlight()); + drawObjectOutline(mouldJig, config.generalHighlight()); } if (config.drawMouldInfoOverlay()) @@ -544,39 +541,74 @@ private void drawKovacIfHandIn(Graphics2D graphics) } } - private void drawActionOverlay(Graphics2D graphics, GameObject gameObject) + private void drawActionLeftInfo(Graphics2D graphics) { + Stage stage = state.getCurrentStage(); + GameObject stageObject = getStageGameObject(stage); + int actionsLeft = state.getActionsLeftInStage(); + int heatLeft = state.getActionsForHeatLevel(); + String text = "Actions left: " + actionsLeft; + LocalPoint textLocation = stageObject.getLocalLocation(); + textLocation = new LocalPoint(textLocation.getX(), textLocation.getY()); + Point canvasLocation = Perspective.getCanvasTextLocation(client, graphics, textLocation, text, 250); + if (canvasLocation == null) + { + return; + } + canvasLocation = new Point(canvasLocation.getX(), canvasLocation.getY() + 10); + OverlayUtil.renderTextLocation(graphics, canvasLocation, text, getHeatColor(actionsLeft, heatLeft)); + } + + private void drawHeatLeftInfo(Graphics2D graphics) + { + Stage stage = state.getCurrentStage(); + GameObject stageObject = getStageGameObject(stage); int actionsLeft = state.getActionsLeftInStage(); int heatLeft = state.getActionsForHeatLevel(); + String text = "Heat left: " + heatLeft; + LocalPoint textLocation = stageObject.getLocalLocation(); + textLocation = new LocalPoint(textLocation.getX(), textLocation.getY()); + Point canvasLocation = Perspective.getCanvasTextLocation(client, graphics, textLocation, text, 250); + if (canvasLocation == null) + { + return; + } + OverlayUtil.renderTextLocation(graphics, canvasLocation, text, getHeatColor(actionsLeft, heatLeft)); + } - // Draw heat left - if (config.drawHeatLeftOverlay()) + private void drawObjectClickbox(Graphics2D graphics, GameObject stageObject, Color color) + { + if (stageObject == null) { - String text = "Heat left: " + heatLeft; - LocalPoint textLocation = gameObject.getLocalLocation(); - textLocation = new LocalPoint(textLocation.getX(), textLocation.getY()); - Point canvasLocation = Perspective.getCanvasTextLocation(client, graphics, textLocation, text, 250); - if (canvasLocation == null) - { - return; - } - OverlayUtil.renderTextLocation(graphics, canvasLocation, text, getHeatColor(actionsLeft, heatLeft)); + return; } - if (config.drawActionLeftOverlay()) - // Draw actions left + + Shape objectClickbox = stageObject.getClickbox(); + if (objectClickbox == null) { - String text = "Actions left: " + actionsLeft; - LocalPoint textLocation = gameObject.getLocalLocation(); - textLocation = new LocalPoint(textLocation.getX(), textLocation.getY()); - Point canvasLocation = Perspective.getCanvasTextLocation(client, graphics, textLocation, text, 250); - if (canvasLocation == null) - { - return; - } - canvasLocation = new Point(canvasLocation.getX(), canvasLocation.getY() + 10); - OverlayUtil.renderTextLocation(graphics, canvasLocation, text, getHeatColor(actionsLeft, heatLeft)); + return; } + + Point mousePosition = client.getMouseCanvasPosition(); + if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY())) + { + graphics.setColor(color.darker()); + } + else + { + graphics.setColor(color); + } + graphics.draw(objectClickbox); + graphics.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 20)); + graphics.fill(objectClickbox); } + + private void drawObjectOutline(GameObject stageObject, Color color) + { + Color _color = new Color(color.getRed(), color.getGreen(), color.getBlue(), config.borderAlpha()); + modelOutlineRenderer.drawOutline(stageObject, config.borderThickness(), _color, config.borderFeather()); + } + } diff --git a/src/main/java/com/toofifty/easygiantsfoundry/HeatActionSolver.java b/src/main/java/com/toofifty/easygiantsfoundry/HeatActionSolver.java index b40a11a..f044ea4 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/HeatActionSolver.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/HeatActionSolver.java @@ -121,13 +121,6 @@ public class HeatActionSolver }; - // index is stage, ordinal order - public static final int[] TOOL_TICK_CYCLE = new int[] { - 5, - 2, - 2 - }; - public static final int MAX_INDEX = DX_1.length; public static final int FAST_INDEX = 10; @@ -222,7 +215,7 @@ public static DurationResult solve( final boolean isStageHeating = stage.isHeating(); // adding tool cycle ticks because the first cycle at a tool is almost always nulled // (unless manually reaching the tile, then clicking the tool) - final int toolDelay = TOOL_TICK_CYCLE[stage.ordinal()]; + final int toolDelay = stage.getToolTickCycle(); final int travelTicks = solveTravelTicks(isRunning, stage, isActionHeating) + toolDelay; final int travelDecay = (int) Math.ceil((double) travelTicks / 2); diff --git a/src/main/java/com/toofifty/easygiantsfoundry/HeatActionStateMachine.java b/src/main/java/com/toofifty/easygiantsfoundry/HeatChangerStateMachine.java similarity index 86% rename from src/main/java/com/toofifty/easygiantsfoundry/HeatActionStateMachine.java rename to src/main/java/com/toofifty/easygiantsfoundry/HeatChangerStateMachine.java index ccf6204..ca4d812 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/HeatActionStateMachine.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/HeatChangerStateMachine.java @@ -8,7 +8,7 @@ */ @Slf4j @Data -public class HeatActionStateMachine +public class HeatChangerStateMachine { /** * Tick counter for heating, -1 means not currently heating. @@ -48,7 +48,7 @@ public class HeatActionStateMachine * The last action the player clicked on. Used for ui overlay to display. * When null, the state-machine will stop() and reset. */ - String actionname = null; + String actionName = null; private EasyGiantsFoundryState state; private EasyGiantsFoundryConfig config; @@ -62,7 +62,7 @@ public class HeatActionStateMachine * @param state the current state of the foundry * @param config the current configuration of the plugin * @param startingHeat the starting heat amount - * @see HeatActionStateMachine#setup(boolean, boolean, String) + * @see HeatChangerStateMachine#setup(boolean, boolean, String) */ public void start(EasyGiantsFoundryState state, EasyGiantsFoundryConfig config, int startingHeat) { @@ -107,7 +107,7 @@ else if (isCooling()) } /** - * Core logic. Runs once on {@link HeatActionStateMachine#start} and assumes synchronization with the game. + * Core logic. Runs once on {@link HeatChangerStateMachine#start} and assumes synchronization with the game. * Calculate the estimated duration and goal heat amount of the heating/cooling action. */ public void updateEstimates() @@ -140,9 +140,9 @@ public void updateEstimates() */ public void setup(boolean isFast, boolean isHeating, String actionName) { - actionFast = isFast; - actionHeating = isHeating; - actionname = actionName; + this.actionFast = isFast; + this.actionHeating = isHeating; + this.actionName = actionName; } /** @@ -152,7 +152,7 @@ public void stop() { heatingTicks = -1; coolingTicks = -1; - actionname = null; + actionName = null; } /** @@ -176,9 +176,14 @@ public boolean isCooling() } /** - * Check if the heating/cooling state is currently idle. Neither heating nor cooling. - * - * @return + * @return Check if the state-machine is currently set-up and waiting to start. + */ + public boolean isPending() { + return actionName != null && heatingTicks < 0 && coolingTicks < 0; + } + + /** + * @return Check if the heating/cooling state is currently idle. Neither heating nor cooling. */ public boolean isIdle() { diff --git a/src/main/java/com/toofifty/easygiantsfoundry/enums/Stage.java b/src/main/java/com/toofifty/easygiantsfoundry/enums/Stage.java index 72a194e..3c950ce 100644 --- a/src/main/java/com/toofifty/easygiantsfoundry/enums/Stage.java +++ b/src/main/java/com/toofifty/easygiantsfoundry/enums/Stage.java @@ -7,9 +7,9 @@ @AllArgsConstructor public enum Stage { - TRIP_HAMMER("Hammer", Heat.HIGH, 20, -25, 4, 14), - GRINDSTONE("Grind", Heat.MED, 10, 15, 7, 19), - POLISHING_WHEEL("Polish", Heat.LOW, 10, -17, 12, 10); + TRIP_HAMMER("Hammer", Heat.HIGH, 20, -25, 4, 14, 5), + GRINDSTONE("Grind", Heat.MED, 10, 15, 7, 19, 2), + POLISHING_WHEEL("Polish", Heat.LOW, 10, -17, 12, 10, 2); private final String name; private final Heat heat; @@ -19,6 +19,9 @@ public enum Stage private final int distanceToLava; private final int distanceToWaterfall; + // Ticks between action + private final int toolTickCycle; + public boolean isHeating() { return heatChange > 0;