Skip to content

Commit

Permalink
Added extra features listed in Issue #5
Browse files Browse the repository at this point in the history
  • Loading branch information
MauveCloud committed Apr 11, 2015
1 parent caa4b0b commit 53b758a
Show file tree
Hide file tree
Showing 24 changed files with 375 additions and 58 deletions.
7 changes: 1 addition & 6 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/AdvancedHeatExchanger.java</file>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/CoolantCell60k.java</file>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/CoolantCell10k.java</file>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/ReactorPlannerFrame.java</file>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/Reactor.java</file>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/Simulator.java</file>
<file>file:/E:/GitHub/Ic2ExpReactorPlanner/src/Ic2ExpReactorPlanner/ReactorComponent.java</file>
</group>
</open-files>
</project-private>
10 changes: 5 additions & 5 deletions src/Ic2ExpReactorPlanner/AdvancedHeatExchanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public void transfer() {
heatableNeighbors.add(component);
}
// Code adapted from decompiled IC2 code, class ItemReactorHeatSwitch, with permission from Thunderdark.
int myHeat = 0;
double myHeat = 0.0;
for (ReactorComponent heatableNeighbor : heatableNeighbors) {
double mymed = getCurrentHeat() * 100.0 / getMaxHeat();
double heatablemed = heatableNeighbor.getCurrentHeat() * 100.0 / heatableNeighbor.getMaxHeat();

int add = (int) (heatableNeighbor.getMaxHeat() / 100.0 * (heatablemed + mymed / 2.0));
double add = (int) (heatableNeighbor.getMaxHeat() / 100.0 * (heatablemed + mymed / 2.0));
if (add > switchSide) {
add = switchSide;
}
Expand All @@ -92,9 +92,9 @@ public void transfer() {
} else if (Math.round(heatablemed * 10.0) / 10.0 == Math.round(mymed * 10.0) / 10.0) {
add = 0;
}
double tempAdd = Math.max(-heatableNeighbor.getCurrentHeat(), add);
myHeat -= tempAdd;
heatableNeighbor.adjustCurrentHeat(tempAdd);
myHeat -= add;
add = heatableNeighbor.adjustCurrentHeat(add);
myHeat += add;
}
double mymed = getCurrentHeat() * 100.0 / getMaxHeat();
double Reactormed = parentReactor.getCurrentHeat() * 100.0 / parentReactor.getMaxHeat();
Expand Down
13 changes: 10 additions & 3 deletions src/Ic2ExpReactorPlanner/AdvancedHeatVent.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,20 @@ public boolean isHeatAcceptor() {

@Override
public void dissipate() {
getParent().ventHeat(Math.min(12, getCurrentHeat()));
adjustCurrentHeat(-Math.min(12, getCurrentHeat()));
final double currentDissipation = Math.min(12, getCurrentHeat());
getParent().ventHeat(currentDissipation);
adjustCurrentHeat(-currentDissipation);
effectiveVentCooling = Math.max(effectiveVentCooling, currentDissipation);
}

@Override
public MaterialsList getMaterials() {
return MATERIALS;
}


@Override
public double getVentCoolingCapacity() {
return 12;
}

}
10 changes: 5 additions & 5 deletions src/Ic2ExpReactorPlanner/ComponentHeatExchanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public void transfer() {
heatableNeighbors.add(component);
}
// Code adapted from decompiled IC2 code, class ItemReactorHeatSwitch, with permission from Thunderdark.
int myHeat = 0;
double myHeat = 0.0;
for (ReactorComponent heatableNeighbor : heatableNeighbors) {
double mymed = getCurrentHeat() * 100.0 / getMaxHeat();
double heatablemed = heatableNeighbor.getCurrentHeat() * 100.0 / heatableNeighbor.getMaxHeat();

int add = (int) (heatableNeighbor.getMaxHeat() / 100.0 * (heatablemed + mymed / 2.0));
double add = (int) (heatableNeighbor.getMaxHeat() / 100.0 * (heatablemed + mymed / 2.0));
if (add > switchSide) {
add = switchSide;
}
Expand All @@ -92,9 +92,9 @@ public void transfer() {
} else if (Math.round(heatablemed * 10.0) / 10.0 == Math.round(mymed * 10.0) / 10.0) {
add = 0;
}
double tempAdd = Math.max(-heatableNeighbor.getCurrentHeat(), add);
myHeat -= tempAdd;
heatableNeighbor.adjustCurrentHeat(tempAdd);
myHeat -= add;
add = heatableNeighbor.adjustCurrentHeat(add);
myHeat += add;
}
adjustCurrentHeat(myHeat);
}
Expand Down
32 changes: 29 additions & 3 deletions src/Ic2ExpReactorPlanner/ComponentHeatVent.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,42 @@ public void dissipate() {
if (component != null && component.isHeatAcceptor()) {
heatableNeighbors.add(component);
}
double dissipatedHeat = 0.0;
for (ReactorComponent heatableNeighbor : heatableNeighbors) {
parentReactor.ventHeat(Math.min(4, heatableNeighbor.getCurrentHeat()));
heatableNeighbor.adjustCurrentHeat(-Math.min(4, heatableNeighbor.getCurrentHeat()));
double rejectedCooling = heatableNeighbor.adjustCurrentHeat(-4.0);
double tempDissipatedHeat = 4 + rejectedCooling;
parentReactor.ventHeat(tempDissipatedHeat);
dissipatedHeat += tempDissipatedHeat;
}

effectiveVentCooling = Math.max(effectiveVentCooling, dissipatedHeat);
}

@Override
public MaterialsList getMaterials() {
return MATERIALS;
}

@Override
public double getVentCoolingCapacity() {
double result = 0.0;
final Reactor parentReactor = getParent();
ReactorComponent component = parentReactor.getComponentAt(getRow() + 1, getColumn());
if (component != null && component.isHeatAcceptor() && !(component instanceof RshCondensator) && !(component instanceof LzhCondensator)) {
result += 4.0;
}
component = parentReactor.getComponentAt(getRow() - 1, getColumn());
if (component != null && component.isHeatAcceptor() && !(component instanceof RshCondensator) && !(component instanceof LzhCondensator)) {
result += 4.0;
}
component = parentReactor.getComponentAt(getRow(), getColumn() - 1);
if (component != null && component.isHeatAcceptor() && !(component instanceof RshCondensator) && !(component instanceof LzhCondensator)) {
result += 4.0;
}
component = parentReactor.getComponentAt(getRow(), getColumn() + 1);
if (component != null && component.isHeatAcceptor() && !(component instanceof RshCondensator) && !(component instanceof LzhCondensator)) {
result += 4.0;
}
return result;
}

}
7 changes: 7 additions & 0 deletions src/Ic2ExpReactorPlanner/CoolantCell10k.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,12 @@ public boolean isHeatAcceptor() {
public MaterialsList getMaterials() {
return MATERIALS;
}

@Override
public double adjustCurrentHeat(double heat) {
currentCellCooling += heat;
bestCellCooling = Math.max(currentCellCooling, bestCellCooling);
return super.adjustCurrentHeat(heat);
}

}
7 changes: 7 additions & 0 deletions src/Ic2ExpReactorPlanner/CoolantCell30k.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,11 @@ public MaterialsList getMaterials() {
return MATERIALS;
}

@Override
public double adjustCurrentHeat(double heat) {
currentCellCooling += heat;
bestCellCooling = Math.max(currentCellCooling, bestCellCooling);
return super.adjustCurrentHeat(heat);
}

}
7 changes: 7 additions & 0 deletions src/Ic2ExpReactorPlanner/CoolantCell60k.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,11 @@ public MaterialsList getMaterials() {
return MATERIALS;
}

@Override
public double adjustCurrentHeat(double heat) {
currentCellCooling += heat;
bestCellCooling = Math.max(currentCellCooling, bestCellCooling);
return super.adjustCurrentHeat(heat);
}

}
8 changes: 7 additions & 1 deletion src/Ic2ExpReactorPlanner/DualFuelRodMox.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public String toString() {
}

@Override
public void generateHeat() {
public double generateHeat() {
int pulses = countNeutronNeighbors() + 2;
int heat = 4 * pulses * (pulses + 1);
final Reactor parentReactor = getParent();
Expand All @@ -40,6 +40,7 @@ public void generateHeat() {
}
handleHeat(heat);
applyDamage(1.0);
return heat;
}

@Override
Expand All @@ -55,4 +56,9 @@ public MaterialsList getMaterials() {
return MATERIALS;
}

@Override
public int getRodCount() {
return 2;
}

}
8 changes: 7 additions & 1 deletion src/Ic2ExpReactorPlanner/DualFuelRodUranium.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public String toString() {
}

@Override
public void generateHeat() {
public double generateHeat() {
int pulses = countNeutronNeighbors() + 2;
int heat = 4 * pulses * (pulses + 1);
handleHeat(heat);
applyDamage(1.0);
return heat;
}

@Override
Expand All @@ -51,4 +52,9 @@ public MaterialsList getMaterials() {
return MATERIALS;
}

@Override
public int getRodCount() {
return 2;
}

}
8 changes: 7 additions & 1 deletion src/Ic2ExpReactorPlanner/FuelRodMox.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public String toString() {
}

@Override
public void generateHeat() {
public double generateHeat() {
int pulses = countNeutronNeighbors() + 1;
int heat = 2 * pulses * (pulses + 1);
final Reactor parentReactor = getParent();
Expand All @@ -40,6 +40,7 @@ public void generateHeat() {
}
handleHeat(heat);
applyDamage(1.0);
return heat;
}

@Override
Expand All @@ -55,4 +56,9 @@ public MaterialsList getMaterials() {
return MATERIALS;
}

@Override
public int getRodCount() {
return 1;
}

}
8 changes: 7 additions & 1 deletion src/Ic2ExpReactorPlanner/FuelRodUranium.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ protected int countNeutronNeighbors() {
}

@Override
public void generateHeat() {
public double generateHeat() {
int pulses = countNeutronNeighbors() + 1;
int heat = 2 * pulses * (pulses + 1);
handleHeat(heat);
applyDamage(1.0);
return heat;
}

@Override
Expand Down Expand Up @@ -110,5 +111,10 @@ protected void handleHeat(final int heat) {
public MaterialsList getMaterials() {
return MATERIALS;
}

@Override
public int getRodCount() {
return 1;
}

}
10 changes: 5 additions & 5 deletions src/Ic2ExpReactorPlanner/HeatExchanger.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public void transfer() {
heatableNeighbors.add(component);
}
// Code adapted from decompiled IC2 code, class ItemReactorHeatSwitch, with permission from Thunderdark.
int myHeat = 0;
double myHeat = 0;
for (ReactorComponent heatableNeighbor : heatableNeighbors) {
double mymed = getCurrentHeat() * 100.0 / getMaxHeat();
double heatablemed = heatableNeighbor.getCurrentHeat() * 100.0 / heatableNeighbor.getMaxHeat();

int add = (int) (heatableNeighbor.getMaxHeat() / 100.0 * (heatablemed + mymed / 2.0));
double add = (int) (heatableNeighbor.getMaxHeat() / 100.0 * (heatablemed + mymed / 2.0));
if (add > switchSide) {
add = switchSide;
}
Expand All @@ -92,9 +92,9 @@ public void transfer() {
} else if (Math.round(heatablemed * 10.0) / 10.0 == Math.round(mymed * 10.0) / 10.0) {
add = 0;
}
double tempAdd = Math.max(-heatableNeighbor.getCurrentHeat(), add);
myHeat -= tempAdd;
heatableNeighbor.adjustCurrentHeat(tempAdd);
myHeat -= add;
add = heatableNeighbor.adjustCurrentHeat(add);
myHeat += add;
}
double mymed = getCurrentHeat() * 100.0 / getMaxHeat();
double Reactormed = parentReactor.getCurrentHeat() * 100.0 / parentReactor.getMaxHeat();
Expand Down
13 changes: 10 additions & 3 deletions src/Ic2ExpReactorPlanner/HeatVent.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,20 @@ public boolean isHeatAcceptor() {

@Override
public void dissipate() {
getParent().ventHeat(Math.min(6, getCurrentHeat()));
adjustCurrentHeat(-Math.min(6, getCurrentHeat()));
final double currentDissipation = Math.min(6, getCurrentHeat());
getParent().ventHeat(currentDissipation);
adjustCurrentHeat(-currentDissipation);
effectiveVentCooling = Math.max(effectiveVentCooling, currentDissipation);
}

@Override
public MaterialsList getMaterials() {
return MATERIALS;
}


@Override
public double getVentCoolingCapacity() {
return 6;
}

}
13 changes: 13 additions & 0 deletions src/Ic2ExpReactorPlanner/LzhCondensator.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,18 @@ public boolean isHeatAcceptor() {
public MaterialsList getMaterials() {
return MATERIALS;
}

@Override
public double adjustCurrentHeat(final double heat) {
if (heat < 0.0) {
return heat;
}
currentCondensatorCooling += heat;
bestCondensatorCooling = Math.max(currentCondensatorCooling, bestCondensatorCooling);
double acceptedHeat = Math.min(heat, getMaxHeat() - heat);
double result = heat - acceptedHeat;
currentHeat += acceptedHeat;
return result;
}

}
3 changes: 2 additions & 1 deletion src/Ic2ExpReactorPlanner/NeutronReflector.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public boolean isNeutronReflector() {
}

@Override
public void generateHeat() {
public double generateHeat() {
final Reactor parentReactor = getParent();
ReactorComponent component = parentReactor.getComponentAt(getRow() + 1, getColumn());
if (component != null && component.isNeutronReflector()) {
Expand All @@ -54,6 +54,7 @@ public void generateHeat() {
if (component != null && component.isNeutronReflector()) {
handleFuelRodDamage(component);
}
return 0.0;
}

private void handleFuelRodDamage(ReactorComponent component) {
Expand Down
13 changes: 10 additions & 3 deletions src/Ic2ExpReactorPlanner/OverclockedHeatVent.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,20 @@ public void dissipate() {
double deltaHeat = Math.min(36, parentReactor.getCurrentHeat());
parentReactor.adjustCurrentHeat(-deltaHeat);
this.adjustCurrentHeat(deltaHeat);
parentReactor.ventHeat(Math.min(20, getCurrentHeat()));
adjustCurrentHeat(-Math.min(20, getCurrentHeat()));
final double currentDissipation = Math.min(20, getCurrentHeat());
parentReactor.ventHeat(currentDissipation);
adjustCurrentHeat(-currentDissipation);
effectiveVentCooling = Math.max(effectiveVentCooling, currentDissipation);
}

@Override
public MaterialsList getMaterials() {
return MATERIALS;
}


@Override
public double getVentCoolingCapacity() {
return 20;
}

}
Loading

0 comments on commit 53b758a

Please sign in to comment.