IndustrialWires/src/main/java/malte0811/industrialWires/util/DualEnergyStorage.java
malte0811 2edc831d19 added Jacobs Ladders, part 1
rendering and sound are done, as well as energy usage
ToDo: finish the dimensions of the different ladders, add models for small+normal, recipes, probably a lot more...
2017-02-26 14:04:23 +01:00

99 lines
2.6 KiB
Java

/*
* This file is part of Industrial Wires.
* Copyright (C) 2016-2017 malte0811
*
* Industrial Wires is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Industrial Wires is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*/
package malte0811.industrialWires.util;
public class DualEnergyStorage {
double storedEU;
double maxEU;
double maxOutEU;
double maxInEU;
public DualEnergyStorage(double maxEU, double maxInEU, double maxOutEU) {
this.maxEU = maxEU;
this.maxInEU = maxInEU;
this.maxOutEU = maxOutEU;
}
public DualEnergyStorage(double maxEU, double maxIoEU) {
this(maxEU, maxIoEU, maxIoEU);
}
public DualEnergyStorage(double maxEU) {
this(maxEU, maxEU, maxEU);
}
public DualEnergyStorage(int maxIF, int maxInIF, int maxOutIF) {
this(ConversionUtil.euPerIfIdeal() * maxIF, ConversionUtil.euPerIfIdeal() * maxInIF, ConversionUtil.euPerIfIdeal() * maxOutIF);
}
public DualEnergyStorage(int maxIF, int maxIoIF) {
this(maxIF, maxIoIF, maxIoIF);
}
public DualEnergyStorage(int maxIF) {
this(maxIF, maxIF, maxIF);
}
public double extractEU(double extractMax, boolean doExtract) {
double extr = Math.min(storedEU, extractMax);
if (doExtract) {
storedEU -= extr;
}
return extr;
}
public double extractIF(int extractMax, boolean doExtract) {
double eu = extractMax * ConversionUtil.euPerIfIdeal();
return ConversionUtil.ifPerEuIdeal() * extractEU(eu, doExtract);
}
public double insertEU(double insertMax, boolean doInsert) {
double ins = Math.min(insertMax, maxEU - storedEU);
if (doInsert) {
storedEU += ins;
}
return ins;
}
public double insertIF(int insertMax, boolean doInsert) {
double eu = insertMax * ConversionUtil.euPerIfIdeal();
return ConversionUtil.ifPerEuIdeal() * insertEU(eu, doInsert);
}
public double getEnergyStoredEU() {
return storedEU;
}
public double getMaxStoredEU() {
return maxEU;
}
public double getEnergyStoredIF() {
return storedEU * ConversionUtil.ifPerEuIdeal();
}
public double getMaxStoredIF() {
return maxEU * ConversionUtil.ifPerEuIdeal();
}
public double getEURequested() {
return Math.min(maxInEU, maxEU - storedEU);
}
}