diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-01-13 00:28:02 +0000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-01-13 00:28:02 +0000 |
commit | 3e519e890249825dc8face0087cc631684d36e8c (patch) | |
tree | 33f667dc118da284af154ffbfe9f926ff55928a8 /src/main/java/Ic2ExpReactorPlanner/components/Vent.java | |
parent | b72a9b138fafceab899c1bd86fee64decb9fb98a (diff) | |
download | GT5-Unofficial-3e519e890249825dc8face0087cc631684d36e8c.tar.gz GT5-Unofficial-3e519e890249825dc8face0087cc631684d36e8c.tar.bz2 GT5-Unofficial-3e519e890249825dc8face0087cc631684d36e8c.zip |
Basically finished work on Reactor Simulator.
Diffstat (limited to 'src/main/java/Ic2ExpReactorPlanner/components/Vent.java')
-rw-r--r-- | src/main/java/Ic2ExpReactorPlanner/components/Vent.java | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/main/java/Ic2ExpReactorPlanner/components/Vent.java b/src/main/java/Ic2ExpReactorPlanner/components/Vent.java new file mode 100644 index 0000000000..a43383f694 --- /dev/null +++ b/src/main/java/Ic2ExpReactorPlanner/components/Vent.java @@ -0,0 +1,110 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Ic2ExpReactorPlanner.components; + +import java.util.ArrayList; +import java.util.List; + +import gregtech.api.objects.GT_ItemStack; + +/** + * Represents some kind of vent in a reactor. + * @author Brian McCloud + */ +public class Vent extends ReactorItem { + + private final int selfVent; + private final int hullDraw; + private final int sideVent; + + public Vent(final int id, final String baseName, GT_ItemStack aItem, final double maxDamage, final double maxHeat, final String sourceMod, + final int selfVent, final int hullDraw, final int sideVent) { + super(id, baseName, aItem, maxDamage, maxHeat, sourceMod); + this.selfVent = selfVent; + this.hullDraw = hullDraw; + this.sideVent = sideVent; + } + + public Vent(final Vent other) { + super(other); + this.selfVent = other.selfVent; + this.hullDraw = other.hullDraw; + this.sideVent = other.sideVent; + } + + @Override + public double dissipate() { + double deltaHeat = Math.min(hullDraw, parent.getCurrentHeat()); + currentHullCooling = deltaHeat; + parent.adjustCurrentHeat(-deltaHeat); + this.adjustCurrentHeat(deltaHeat); + final double currentDissipation = Math.min(selfVent, getCurrentHeat()); + currentVentCooling = currentDissipation; + parent.ventHeat(currentDissipation); + adjustCurrentHeat(-currentDissipation); + if (sideVent > 0) { + List<ReactorItem> coolableNeighbors = new ArrayList<>(4); + ReactorItem component = parent.getComponentAt(row - 1, col); + if (component != null && component.isCoolable()) { + coolableNeighbors.add(component); + } + component = parent.getComponentAt(row, col + 1); + if (component != null && component.isCoolable()) { + coolableNeighbors.add(component); + } + component = parent.getComponentAt(row + 1, col); + if (component != null && component.isCoolable()) { + coolableNeighbors.add(component); + } + component = parent.getComponentAt(row, col - 1); + if (component != null && component.isCoolable()) { + coolableNeighbors.add(component); + } + for (ReactorItem coolableNeighbor : coolableNeighbors) { + double rejectedCooling = coolableNeighbor.adjustCurrentHeat(-sideVent); + double tempDissipatedHeat = sideVent + rejectedCooling; + parent.ventHeat(tempDissipatedHeat); + currentVentCooling += tempDissipatedHeat; + } + } + bestVentCooling = Math.max(bestVentCooling, currentVentCooling); + return currentDissipation; + } + + @Override + public double getVentCoolingCapacity() { + double result = selfVent; + if (sideVent > 0) { + ReactorItem component = parent.getComponentAt(row - 1, col); + if (component != null && component.isCoolable()) { + result += sideVent; + } + component = parent.getComponentAt(row, col + 1); + if (component != null && component.isCoolable()) { + result += sideVent; + } + component = parent.getComponentAt(row + 1, col); + if (component != null && component.isCoolable()) { + result += sideVent; + } + component = parent.getComponentAt(row, col - 1); + if (component != null && component.isCoolable()) { + result += sideVent; + } + } + return result; + } + + @Override + public double getHullCoolingCapacity() { + return hullDraw; + } + + @Override + public double getCurrentOutput() { + return currentVentCooling; + } + } |