Skip to content

Commit

Permalink
Added support for Reactor Coolant Injectors
Browse files Browse the repository at this point in the history
  • Loading branch information
MauveCloud committed Nov 11, 2017
1 parent 394c3ce commit 1bebfb9
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Ic2ExpReactorPlanner/AutomationSimulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public class AutomationSimulator extends SwingWorker<Void, String> {

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,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down
3 changes: 3 additions & 0 deletions src/Ic2ExpReactorPlanner/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions src/Ic2ExpReactorPlanner/LzhCondensator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
19 changes: 19 additions & 0 deletions src/Ic2ExpReactorPlanner/PulsedSimulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public class PulsedSimulator extends SwingWorker<Void, String> {

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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
18 changes: 18 additions & 0 deletions src/Ic2ExpReactorPlanner/Reactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}

}
15 changes: 15 additions & 0 deletions src/Ic2ExpReactorPlanner/ReactorPlannerFrame.form
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,21 @@
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JCheckBox" name="reactorCoolantInjectorCheckbox">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="Ic2ExpReactorPlanner/Bundle.properties" key="ReactorPlannerFrame.reactorCoolantInjectorCheckbox.text" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="reactorCoolantInjectorCheckboxActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
</Container>
</SubComponents>
Expand Down
18 changes: 18 additions & 0 deletions src/Ic2ExpReactorPlanner/ReactorPlannerFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<Void, String> simulator;

Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/Ic2ExpReactorPlanner/RshCondensator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
19 changes: 19 additions & 0 deletions src/Ic2ExpReactorPlanner/SimpleSimulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public class SimpleSimulator extends SwingWorker<Void, String> {

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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 1bebfb9

Please sign in to comment.