diff --git a/src/Ic2ExpReactorPlanner/AutomationSimulator.java b/src/Ic2ExpReactorPlanner/AutomationSimulator.java index aaf89ab..9b9dee2 100644 --- a/src/Ic2ExpReactorPlanner/AutomationSimulator.java +++ b/src/Ic2ExpReactorPlanner/AutomationSimulator.java @@ -45,6 +45,10 @@ public class AutomationSimulator extends SwingWorker { private int nextOnTime = 0; + private int redstoneUsed = 0; + + private int lapisUsed = 0; + private MaterialsList replacedItems = new MaterialsList(); public AutomationSimulator(final Reactor reactor, final JTextArea output, final JPanel[][] reactorButtonPanels, final int initialHeat, @@ -228,6 +232,15 @@ protected Void doInBackground() throws Exception { } } } + if (reactor.isUsingReactorCoolantInjectors()) { + if (component instanceof RshCondensator && component.getCurrentHeat() > 17000 && !component.isBroken()) { + ((RshCondensator) component).injectCoolant(); + redstoneUsed++; + } else if (component instanceof LzhCondensator && component.getCurrentHeat() > 85000 && !component.isBroken()) { + ((LzhCondensator) component).injectCoolant(); + lapisUsed++; + } + } } } if (!active) { @@ -311,6 +324,12 @@ protected Void doInBackground() throws Exception { publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("TOTAL_CELL_COOLING"), totalCellCooling)); publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("TOTAL_CONDENSATOR_COOLING"), totalCondensatorCooling)); publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("MAX_HEAT_GENERATED"), maxGeneratedHeat)); + if (redstoneUsed > 0) { + publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("REDSTONE_USED"), redstoneUsed)); + } + if (lapisUsed > 0) { + publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("LAPIS_USED"), lapisUsed)); + } double totalCooling = totalEffectiveVentCooling + totalCellCooling + totalCondensatorCooling; if (totalCooling >= maxGeneratedHeat) { publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("EXCESS_COOLING"), totalCooling - maxGeneratedHeat)); diff --git a/src/Ic2ExpReactorPlanner/Bundle.properties b/src/Ic2ExpReactorPlanner/Bundle.properties index 8302e2b..d300e56 100644 --- a/src/Ic2ExpReactorPlanner/Bundle.properties +++ b/src/Ic2ExpReactorPlanner/Bundle.properties @@ -243,3 +243,6 @@ THICK\ NEUTRON\ REFLECTOR=Thick Neutron Reflector HEAT_BUILDUP=Reactor heat buildup per tick (while all components are intact):%.2f minimum, %.2f maximum.\n ReactorPlannerFrame.jLabel16.text=(both temps can be set to match explode temp to mimic having no temperature control) ReactorPlannerFrame.jScrollPane3.TabConstraints.tabTitle=Component List +ReactorPlannerFrame.reactorCoolantInjectorCheckbox.text=Use Reactor Coolant Injectors (MC 1.8+ only) +REDSTONE_USED=Used %d Blocks of Redstone.\n +LAPIS_USED=Used %d Lapis Lazuli Blocks.\n diff --git a/src/Ic2ExpReactorPlanner/LzhCondensator.java b/src/Ic2ExpReactorPlanner/LzhCondensator.java index d8ca6ce..45e8109 100644 --- a/src/Ic2ExpReactorPlanner/LzhCondensator.java +++ b/src/Ic2ExpReactorPlanner/LzhCondensator.java @@ -58,4 +58,11 @@ public double adjustCurrentHeat(final double heat) { return result; } + /** + * Simulates having a coolant item added by a Reactor Coolant Injector. + */ + public void injectCoolant() { + currentHeat = 0; + } + } diff --git a/src/Ic2ExpReactorPlanner/PulsedSimulator.java b/src/Ic2ExpReactorPlanner/PulsedSimulator.java index 3875c83..5ee4a00 100644 --- a/src/Ic2ExpReactorPlanner/PulsedSimulator.java +++ b/src/Ic2ExpReactorPlanner/PulsedSimulator.java @@ -45,6 +45,10 @@ public class PulsedSimulator extends SwingWorker { private int nextOnTime = 0; + private int redstoneUsed = 0; + + private int lapisUsed = 0; + public PulsedSimulator(final Reactor reactor, final JTextArea output, final JPanel[][] reactorButtonPanels, final int initialHeat, final int onPulseDuration, final int offPulseDuration, final int suspendTemp, final int resumeTemp) { this.reactor = reactor; @@ -194,6 +198,15 @@ protected Void doInBackground() throws Exception { alreadyBroken[row][col] = true; publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("BROKE_TIME"), row, col, reactorTicks)); } + if (reactor.isUsingReactorCoolantInjectors()) { + if (component instanceof RshCondensator && component.getCurrentHeat() > 17000 && !component.isBroken()) { + ((RshCondensator) component).injectCoolant(); + redstoneUsed++; + } else if (component instanceof LzhCondensator && component.getCurrentHeat() > 85000 && !component.isBroken()) { + ((LzhCondensator) component).injectCoolant(); + lapisUsed++; + } + } } } } while (reactor.getCurrentHeat() <= reactor.getMaxHeat() && (!allFuelRodsDepleted || lastEUoutput > 0 || lastHeatOutput > 0) && reactorTicks < 5000000); @@ -256,6 +269,12 @@ protected Void doInBackground() throws Exception { publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("TOTAL_CELL_COOLING"), totalCellCooling)); publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("TOTAL_CONDENSATOR_COOLING"), totalCondensatorCooling)); publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("MAX_HEAT_GENERATED"), maxGeneratedHeat)); + if (redstoneUsed > 0) { + publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("REDSTONE_USED"), redstoneUsed)); + } + if (lapisUsed > 0) { + publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("LAPIS_USED"), lapisUsed)); + } double totalCooling = totalEffectiveVentCooling + totalCellCooling + totalCondensatorCooling; if (totalCooling >= maxGeneratedHeat) { publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("EXCESS_COOLING"), totalCooling - maxGeneratedHeat)); diff --git a/src/Ic2ExpReactorPlanner/Reactor.java b/src/Ic2ExpReactorPlanner/Reactor.java index aa96910..3f7c636 100644 --- a/src/Ic2ExpReactorPlanner/Reactor.java +++ b/src/Ic2ExpReactorPlanner/Reactor.java @@ -25,6 +25,8 @@ public class Reactor { private boolean fluid = false; + private boolean usingReactorCoolantInjectors = false; + public ReactorComponent getComponentAt(int row, int column) { if (row >= 0 && row < grid.length && column >= 0 && column < grid[row].length) { return grid[row][column]; @@ -396,4 +398,20 @@ public void setFluid(boolean fluid) { this.fluid = fluid; } + /** + * Checks whether the reactor is using Reactor Coolant Injectors (RCIs) + * @return true if this reactor was set to use RCIs, false otherwise. + */ + public boolean isUsingReactorCoolantInjectors() { + return usingReactorCoolantInjectors; + } + + /** + * Sets whether the reactor is to use Reactor Coolant Injectors (RCIs) + * @param usingReactorCoolantInjectors true if this reactor should use RCIs, false otherwise. + */ + public void setUsingReactorCoolantInjectors(boolean usingReactorCoolantInjectors) { + this.usingReactorCoolantInjectors = usingReactorCoolantInjectors; + } + } diff --git a/src/Ic2ExpReactorPlanner/ReactorPlannerFrame.form b/src/Ic2ExpReactorPlanner/ReactorPlannerFrame.form index 0843ed7..1875efc 100644 --- a/src/Ic2ExpReactorPlanner/ReactorPlannerFrame.form +++ b/src/Ic2ExpReactorPlanner/ReactorPlannerFrame.form @@ -804,6 +804,21 @@ + + + + + + + + + + + + + + + diff --git a/src/Ic2ExpReactorPlanner/ReactorPlannerFrame.java b/src/Ic2ExpReactorPlanner/ReactorPlannerFrame.java index d1d7f70..bf2d809 100644 --- a/src/Ic2ExpReactorPlanner/ReactorPlannerFrame.java +++ b/src/Ic2ExpReactorPlanner/ReactorPlannerFrame.java @@ -298,6 +298,7 @@ private void initComponents() { pasteCodeButton = new javax.swing.JButton(); jLabel6 = new javax.swing.JLabel(); simulationStyleCombo = new javax.swing.JComboBox<>(); + reactorCoolantInjectorCheckbox = new javax.swing.JCheckBox(); outputTabs = new javax.swing.JTabbedPane(); outputPane = new javax.swing.JScrollPane(); outputArea = new javax.swing.JTextArea(); @@ -714,6 +715,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); jPanel1.add(simulationStyleCombo, gridBagConstraints); + reactorCoolantInjectorCheckbox.setText(bundle.getString("ReactorPlannerFrame.reactorCoolantInjectorCheckbox.text")); // NOI18N + reactorCoolantInjectorCheckbox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + reactorCoolantInjectorCheckboxActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + jPanel1.add(reactorCoolantInjectorCheckbox, gridBagConstraints); + jSplitPane3.setBottomComponent(jPanel1); jSplitPane2.setRightComponent(jSplitPane3); @@ -993,6 +1005,7 @@ private void simulateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GE simulatedReactor = new Reactor(); simulatedReactor.setCode(reactor.getCode()); simulatedReactor.setFluid(reactor.isFluid()); + simulatedReactor.setUsingReactorCoolantInjectors(reactor.isUsingReactorCoolantInjectors()); outputTabs.setSelectedIndex(0); if ("Simple Cycle".equals(simulationStyleCombo.getSelectedItem().toString())) { simulator = new SimpleSimulator(simulatedReactor, outputArea, reactorButtonPanels, initialHeat); @@ -1087,6 +1100,10 @@ private void pauseSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN- component.reactorPause = ((Number)pauseSpinner.getValue()).intValue(); } }//GEN-LAST:event_pauseSpinnerStateChanged + + private void reactorCoolantInjectorCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reactorCoolantInjectorCheckboxActionPerformed + reactor.setUsingReactorCoolantInjectors(reactorCoolantInjectorCheckbox.isSelected()); + }//GEN-LAST:event_reactorCoolantInjectorCheckboxActionPerformed private SwingWorker simulator; @@ -1218,6 +1235,7 @@ public void run() { private javax.swing.JToggleButton quadFuelRodMoxButton; private javax.swing.JToggleButton quadFuelRodThoriumButton; private javax.swing.JToggleButton quadFuelRodUraniumButton; + private javax.swing.JCheckBox reactorCoolantInjectorCheckbox; private javax.swing.JToggleButton reactorHeatVentButton; private javax.swing.JPanel reactorPanel; private javax.swing.JToggleButton reactorPlatingButton; diff --git a/src/Ic2ExpReactorPlanner/RshCondensator.java b/src/Ic2ExpReactorPlanner/RshCondensator.java index f550d6f..f261635 100644 --- a/src/Ic2ExpReactorPlanner/RshCondensator.java +++ b/src/Ic2ExpReactorPlanner/RshCondensator.java @@ -58,4 +58,11 @@ public double adjustCurrentHeat(final double heat) { return result; } + /** + * Simulates having a coolant item added by a Reactor Coolant Injector. + */ + public void injectCoolant() { + currentHeat = 0; + } + } diff --git a/src/Ic2ExpReactorPlanner/SimpleSimulator.java b/src/Ic2ExpReactorPlanner/SimpleSimulator.java index 98d8780..4510694 100644 --- a/src/Ic2ExpReactorPlanner/SimpleSimulator.java +++ b/src/Ic2ExpReactorPlanner/SimpleSimulator.java @@ -33,6 +33,10 @@ public class SimpleSimulator extends SwingWorker { private double maxHeatOutput = 0.0; + private int redstoneUsed = 0; + + private int lapisUsed = 0; + public SimpleSimulator(final Reactor reactor, final JTextArea output, final JPanel[][] reactorButtonPanels, final int initialHeat) { this.reactor = reactor; this.output = output; @@ -160,6 +164,15 @@ protected Void doInBackground() throws Exception { timeToFirstComponentBreak = reactorTicks; } } + if (reactor.isUsingReactorCoolantInjectors()) { + if (component instanceof RshCondensator && component.getCurrentHeat() > 17000 && !component.isBroken()) { + ((RshCondensator) component).injectCoolant(); + redstoneUsed++; + } else if (component instanceof LzhCondensator && component.getCurrentHeat() > 85000 && !component.isBroken()) { + ((LzhCondensator) component).injectCoolant(); + lapisUsed++; + } + } } } if (componentsIntact && postTickReactorHeat >= preTickReactorHeat) { @@ -297,6 +310,12 @@ protected Void doInBackground() throws Exception { publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("TOTAL_CELL_COOLING"), totalCellCooling)); publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("TOTAL_CONDENSATOR_COOLING"), totalCondensatorCooling)); publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("MAX_HEAT_GENERATED"), maxGeneratedHeat)); + if (redstoneUsed > 0) { + publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("REDSTONE_USED"), redstoneUsed)); + } + if (lapisUsed > 0) { + publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("LAPIS_USED"), lapisUsed)); + } double totalCooling = totalEffectiveVentCooling + totalCellCooling + totalCondensatorCooling; if (maxHeatBuildup > 0) { publish(String.format(java.util.ResourceBundle.getBundle("Ic2ExpReactorPlanner/Bundle").getString("HEAT_BUILDUP"), minHeatBuildup, maxHeatBuildup));