2013-08-27 00:49:32 +02:00
|
|
|
package mekanism.api.gas;
|
2013-06-26 23:49:47 +02:00
|
|
|
|
|
|
|
import java.util.Arrays;
|
2013-08-19 03:32:47 +02:00
|
|
|
import java.util.Collection;
|
2013-06-26 23:49:47 +02:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2014-01-03 03:58:14 +01:00
|
|
|
import mekanism.api.ListUtils;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.api.transmitters.DynamicNetwork;
|
2013-12-21 01:12:33 +01:00
|
|
|
import mekanism.api.transmitters.IGridTransmitter;
|
2013-12-18 02:28:25 +01:00
|
|
|
import mekanism.api.transmitters.ITransmitterNetwork;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.api.transmitters.TransmissionType;
|
2013-06-26 23:49:47 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraftforge.common.ForgeDirection;
|
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
import net.minecraftforge.event.Event;
|
|
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
|
|
|
|
2013-12-23 23:06:22 +01:00
|
|
|
/**
|
|
|
|
* A DynamicNetwork extension created specifically for the transfer of Gasses. By default this is server-only, but if ticked on
|
|
|
|
* the client side and if it's posted events are handled properly, it has the capability to visually display gasses network-wide.
|
|
|
|
* @author aidancbrady
|
|
|
|
*
|
|
|
|
*/
|
2013-12-12 22:54:55 +01:00
|
|
|
public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
2013-11-25 22:34:59 +01:00
|
|
|
public int transferDelay = 0;
|
|
|
|
|
2013-11-29 03:43:53 +01:00
|
|
|
public boolean didTransfer;
|
|
|
|
public boolean prevTransfer;
|
2013-11-25 22:34:59 +01:00
|
|
|
|
2013-11-29 03:43:53 +01:00
|
|
|
public float gasScale;
|
2013-11-25 22:34:59 +01:00
|
|
|
|
2013-12-18 02:28:25 +01:00
|
|
|
public Gas refGas;
|
|
|
|
|
2013-12-14 06:36:52 +01:00
|
|
|
public GasStack gasStored;
|
2013-12-18 00:20:18 +01:00
|
|
|
public int prevStored;
|
2013-12-14 06:36:52 +01:00
|
|
|
|
2013-12-21 01:12:33 +01:00
|
|
|
public GasNetwork(IGridTransmitter<GasNetwork>... varPipes)
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
2013-08-17 19:32:05 +02:00
|
|
|
transmitters.addAll(Arrays.asList(varPipes));
|
2013-08-04 02:41:16 +02:00
|
|
|
register();
|
|
|
|
}
|
|
|
|
|
2013-12-21 01:12:33 +01:00
|
|
|
public GasNetwork(Collection<IGridTransmitter<GasNetwork>> collection)
|
2013-08-19 03:32:47 +02:00
|
|
|
{
|
|
|
|
transmitters.addAll(collection);
|
|
|
|
register();
|
|
|
|
}
|
|
|
|
|
2013-08-04 02:41:16 +02:00
|
|
|
public GasNetwork(Set<GasNetwork> networks)
|
|
|
|
{
|
|
|
|
for(GasNetwork net : networks)
|
|
|
|
{
|
|
|
|
if(net != null)
|
|
|
|
{
|
2013-12-18 17:19:30 +01:00
|
|
|
if(FMLCommonHandler.instance().getEffectiveSide().isClient())
|
2013-11-29 19:04:39 +01:00
|
|
|
{
|
2013-12-18 17:19:30 +01:00
|
|
|
if(net.refGas != null && net.gasScale > gasScale)
|
2013-12-17 18:53:33 +01:00
|
|
|
{
|
2013-12-18 17:19:30 +01:00
|
|
|
gasScale = net.gasScale;
|
|
|
|
refGas = net.refGas;
|
2013-12-17 18:53:33 +01:00
|
|
|
gasStored = net.gasStored;
|
2013-12-18 17:19:30 +01:00
|
|
|
|
|
|
|
net.gasScale = 0;
|
|
|
|
net.refGas = null;
|
|
|
|
net.gasStored = null;
|
2013-12-17 18:53:33 +01:00
|
|
|
}
|
2013-12-18 17:19:30 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(net.gasStored != null)
|
|
|
|
{
|
|
|
|
if(gasStored == null)
|
|
|
|
{
|
|
|
|
gasStored = net.gasStored;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gasStored.amount += net.gasStored.amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
net.gasStored = null;
|
2013-12-17 18:53:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-17 19:32:05 +02:00
|
|
|
addAllTransmitters(net.transmitters);
|
2013-08-04 02:41:16 +02:00
|
|
|
net.deregister();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-18 17:19:30 +01:00
|
|
|
gasScale = getScale();
|
|
|
|
|
2013-08-04 02:41:16 +02:00
|
|
|
refresh();
|
|
|
|
register();
|
2013-06-26 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
2013-12-17 18:53:33 +01:00
|
|
|
@Override
|
|
|
|
public void onNetworksCreated(List<GasNetwork> networks)
|
|
|
|
{
|
2013-12-18 17:19:30 +01:00
|
|
|
if(gasStored != null && FMLCommonHandler.instance().getEffectiveSide().isServer())
|
2013-12-18 02:28:25 +01:00
|
|
|
{
|
|
|
|
int[] caps = new int[networks.size()];
|
|
|
|
int cap = 0;
|
|
|
|
|
|
|
|
for(GasNetwork network : networks)
|
|
|
|
{
|
|
|
|
caps[networks.indexOf(network)] = network.getCapacity();
|
|
|
|
cap += network.getCapacity();
|
|
|
|
}
|
|
|
|
|
|
|
|
gasStored.amount = Math.min(cap, gasStored.amount);
|
|
|
|
|
|
|
|
int[] values = ListUtils.calcPercentInt(ListUtils.percent(caps), gasStored.amount);
|
|
|
|
|
|
|
|
for(GasNetwork network : networks)
|
|
|
|
{
|
|
|
|
int index = networks.indexOf(network);
|
|
|
|
|
|
|
|
if(values[index] > 0)
|
|
|
|
{
|
|
|
|
network.gasStored = new GasStack(gasStored.getGas(), values[index]);
|
|
|
|
network.refGas = gasStored.getGas();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-18 02:42:52 +01:00
|
|
|
|
|
|
|
gasScale = 0;
|
|
|
|
refGas = null;
|
|
|
|
gasStored = null;
|
2013-12-17 18:53:33 +01:00
|
|
|
}
|
|
|
|
|
2013-12-14 06:36:52 +01:00
|
|
|
public synchronized int getGasNeeded()
|
|
|
|
{
|
|
|
|
return getCapacity()-(gasStored != null ? gasStored.amount : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public synchronized int tickEmit(GasStack stack)
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
2013-11-27 02:11:26 +01:00
|
|
|
List availableAcceptors = Arrays.asList(getAcceptors(stack.getGas()).toArray());
|
2013-06-26 23:49:47 +02:00
|
|
|
|
|
|
|
Collections.shuffle(availableAcceptors);
|
|
|
|
|
2013-11-27 02:11:26 +01:00
|
|
|
int toSend = stack.amount;
|
|
|
|
int prevSending = toSend;
|
2013-06-26 23:49:47 +02:00
|
|
|
|
|
|
|
if(!availableAcceptors.isEmpty())
|
|
|
|
{
|
|
|
|
int divider = availableAcceptors.size();
|
2013-11-27 02:11:26 +01:00
|
|
|
int remaining = toSend % divider;
|
|
|
|
int sending = (toSend-remaining)/divider;
|
2013-06-26 23:49:47 +02:00
|
|
|
|
|
|
|
for(Object obj : availableAcceptors)
|
|
|
|
{
|
2013-12-14 06:36:52 +01:00
|
|
|
if(obj instanceof IGasHandler)
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
2013-12-12 22:54:55 +01:00
|
|
|
IGasHandler acceptor = (IGasHandler)obj;
|
2013-06-26 23:49:47 +02:00
|
|
|
|
|
|
|
int currentSending = sending;
|
|
|
|
|
|
|
|
if(remaining > 0)
|
|
|
|
{
|
|
|
|
currentSending++;
|
|
|
|
remaining--;
|
|
|
|
}
|
|
|
|
|
2013-12-12 22:54:55 +01:00
|
|
|
toSend -= acceptor.receiveGas(acceptorDirections.get(acceptor).getOpposite(), new GasStack(stack.getGas(), currentSending));
|
2013-06-26 23:49:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-27 02:11:26 +01:00
|
|
|
int sent = prevSending-toSend;
|
2013-11-25 22:34:59 +01:00
|
|
|
|
|
|
|
if(sent > 0 && FMLCommonHandler.instance().getEffectiveSide().isServer())
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
2013-11-29 03:43:53 +01:00
|
|
|
didTransfer = true;
|
2013-11-25 22:34:59 +01:00
|
|
|
transferDelay = 2;
|
2013-06-26 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
2013-11-27 02:11:26 +01:00
|
|
|
return sent;
|
2013-06-26 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
2013-12-14 06:36:52 +01:00
|
|
|
public synchronized int emit(GasStack stack)
|
|
|
|
{
|
2013-12-17 20:39:30 +01:00
|
|
|
if(gasStored != null && gasStored.getGas() != stack.getGas())
|
2013-12-14 06:36:52 +01:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int toUse = Math.min(getGasNeeded(), stack.amount);
|
|
|
|
|
|
|
|
if(gasStored == null)
|
|
|
|
{
|
|
|
|
gasStored = stack.copy();
|
|
|
|
gasStored.amount = toUse;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gasStored.amount += toUse;
|
|
|
|
}
|
|
|
|
|
|
|
|
return toUse;
|
|
|
|
}
|
|
|
|
|
2013-11-25 22:34:59 +01:00
|
|
|
@Override
|
2013-12-21 20:54:12 +01:00
|
|
|
public void onUpdate()
|
2013-11-25 22:34:59 +01:00
|
|
|
{
|
2013-12-21 20:54:12 +01:00
|
|
|
super.onUpdate();
|
2013-11-25 22:34:59 +01:00
|
|
|
|
|
|
|
if(FMLCommonHandler.instance().getEffectiveSide().isServer())
|
|
|
|
{
|
|
|
|
if(transferDelay == 0)
|
|
|
|
{
|
2013-11-29 03:43:53 +01:00
|
|
|
didTransfer = false;
|
2013-11-25 22:34:59 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
transferDelay--;
|
|
|
|
}
|
|
|
|
|
2013-12-18 00:20:18 +01:00
|
|
|
int stored = gasStored != null ? gasStored.amount : 0;
|
|
|
|
|
|
|
|
if(stored != prevStored)
|
2013-12-14 21:30:41 +01:00
|
|
|
{
|
|
|
|
needsUpdate = true;
|
|
|
|
}
|
|
|
|
|
2013-12-18 00:20:18 +01:00
|
|
|
prevStored = stored;
|
2013-12-14 21:30:41 +01:00
|
|
|
|
2013-11-29 03:43:53 +01:00
|
|
|
if(didTransfer != prevTransfer || needsUpdate)
|
2013-11-25 22:34:59 +01:00
|
|
|
{
|
2013-12-18 00:20:18 +01:00
|
|
|
MinecraftForge.EVENT_BUS.post(new GasTransferEvent(this, gasStored, didTransfer));
|
2013-11-29 03:43:53 +01:00
|
|
|
needsUpdate = false;
|
2013-11-25 22:34:59 +01:00
|
|
|
}
|
|
|
|
|
2013-11-29 03:43:53 +01:00
|
|
|
prevTransfer = didTransfer;
|
2013-12-14 06:36:52 +01:00
|
|
|
|
|
|
|
if(gasStored != null)
|
|
|
|
{
|
2013-12-15 06:03:45 +01:00
|
|
|
gasStored.amount -= tickEmit(gasStored);
|
2013-12-14 06:36:52 +01:00
|
|
|
|
|
|
|
if(gasStored.amount <= 0)
|
|
|
|
{
|
|
|
|
gasStored = null;
|
|
|
|
}
|
|
|
|
}
|
2013-11-29 03:43:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void clientTick()
|
|
|
|
{
|
|
|
|
super.clientTick();
|
|
|
|
|
2013-12-18 00:20:18 +01:00
|
|
|
gasScale = Math.max(gasScale, getScale());
|
2013-12-17 20:45:30 +01:00
|
|
|
|
2013-11-29 03:43:53 +01:00
|
|
|
if(didTransfer && gasScale < 1)
|
|
|
|
{
|
2013-12-18 00:20:18 +01:00
|
|
|
gasScale = Math.max(getScale(), Math.min(1, gasScale+0.02F));
|
2013-11-29 03:43:53 +01:00
|
|
|
}
|
|
|
|
else if(!didTransfer && gasScale > 0)
|
|
|
|
{
|
2013-12-18 00:20:18 +01:00
|
|
|
gasScale = Math.max(getScale(), Math.max(0, gasScale-0.02F));
|
2013-11-29 03:43:53 +01:00
|
|
|
|
|
|
|
if(gasScale == 0)
|
|
|
|
{
|
2013-12-18 00:20:18 +01:00
|
|
|
gasStored = null;
|
2013-11-29 03:43:53 +01:00
|
|
|
}
|
2013-11-25 22:34:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-18 22:51:47 +02:00
|
|
|
@Override
|
2013-12-12 22:54:55 +01:00
|
|
|
public synchronized Set<IGasHandler> getAcceptors(Object... data)
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
2013-11-27 02:11:26 +01:00
|
|
|
Gas type = (Gas)data[0];
|
2013-12-12 22:54:55 +01:00
|
|
|
Set<IGasHandler> toReturn = new HashSet<IGasHandler>();
|
2013-06-26 23:49:47 +02:00
|
|
|
|
2013-12-12 22:54:55 +01:00
|
|
|
for(IGasHandler acceptor : possibleAcceptors)
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
2013-12-12 22:54:55 +01:00
|
|
|
if(acceptorDirections.get(acceptor) == null)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-11-27 02:11:26 +01:00
|
|
|
if(acceptor.canReceiveGas(acceptorDirections.get(acceptor).getOpposite(), type))
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
2013-12-12 22:54:55 +01:00
|
|
|
toReturn.add(acceptor);
|
2013-06-26 23:49:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return toReturn;
|
|
|
|
}
|
|
|
|
|
2013-08-18 22:51:47 +02:00
|
|
|
@Override
|
2013-10-20 06:04:11 +02:00
|
|
|
public synchronized void refresh()
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
2013-12-21 01:12:33 +01:00
|
|
|
Set<IGridTransmitter<GasNetwork>> iterTubes = (Set<IGridTransmitter<GasNetwork>>)transmitters.clone();
|
|
|
|
Iterator<IGridTransmitter<GasNetwork>> it = iterTubes.iterator();
|
2013-06-26 23:49:47 +02:00
|
|
|
|
|
|
|
possibleAcceptors.clear();
|
|
|
|
acceptorDirections.clear();
|
|
|
|
|
|
|
|
while(it.hasNext())
|
|
|
|
{
|
2013-12-21 01:12:33 +01:00
|
|
|
IGridTransmitter<GasNetwork> conductor = (IGridTransmitter<GasNetwork>)it.next();
|
2013-06-26 23:49:47 +02:00
|
|
|
|
2013-08-04 02:41:16 +02:00
|
|
|
if(conductor == null || ((TileEntity)conductor).isInvalid())
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
|
|
|
it.remove();
|
2013-08-17 19:32:05 +02:00
|
|
|
transmitters.remove(conductor);
|
2013-06-26 23:49:47 +02:00
|
|
|
}
|
|
|
|
else {
|
2013-08-27 01:04:00 +02:00
|
|
|
conductor.setTransmitterNetwork(this);
|
2013-06-26 23:49:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-21 01:12:33 +01:00
|
|
|
for(IGridTransmitter<GasNetwork> transmitter : transmitters)
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
2013-12-18 22:23:07 +01:00
|
|
|
IGasHandler[] acceptors = GasTransmission.getConnectedAcceptors((TileEntity)transmitter);
|
2013-06-26 23:49:47 +02:00
|
|
|
|
2013-12-12 22:54:55 +01:00
|
|
|
for(IGasHandler acceptor : acceptors)
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
2013-12-18 22:23:07 +01:00
|
|
|
ForgeDirection side = ForgeDirection.getOrientation(Arrays.asList(acceptors).indexOf(acceptor));
|
|
|
|
|
2014-01-03 18:13:49 +01:00
|
|
|
if(side != null && acceptor != null && !(acceptor instanceof IGridTransmitter) && transmitter.canConnectToAcceptor(side, true))
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
|
|
|
possibleAcceptors.add(acceptor);
|
|
|
|
acceptorDirections.put(acceptor, ForgeDirection.getOrientation(Arrays.asList(acceptors).indexOf(acceptor)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-18 22:51:47 +02:00
|
|
|
@Override
|
2013-10-20 06:04:11 +02:00
|
|
|
public synchronized void merge(GasNetwork network)
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
|
|
|
if(network != null && network != this)
|
|
|
|
{
|
2013-08-04 02:41:16 +02:00
|
|
|
Set<GasNetwork> networks = new HashSet();
|
|
|
|
networks.add(this);
|
|
|
|
networks.add(network);
|
2013-11-29 03:43:53 +01:00
|
|
|
GasNetwork newNetwork = create(networks);
|
2013-06-26 23:49:47 +02:00
|
|
|
newNetwork.refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static class GasTransferEvent extends Event
|
|
|
|
{
|
|
|
|
public final GasNetwork gasNetwork;
|
|
|
|
|
2013-12-18 00:20:18 +01:00
|
|
|
public final GasStack transferType;
|
2013-11-29 03:43:53 +01:00
|
|
|
public final boolean didTransfer;
|
2013-06-26 23:49:47 +02:00
|
|
|
|
2013-12-18 00:20:18 +01:00
|
|
|
public GasTransferEvent(GasNetwork network, GasStack type, boolean did)
|
2013-06-26 23:49:47 +02:00
|
|
|
{
|
|
|
|
gasNetwork = network;
|
|
|
|
transferType = type;
|
2013-11-29 03:43:53 +01:00
|
|
|
didTransfer = did;
|
2013-06-26 23:49:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-14 21:30:41 +01:00
|
|
|
public float getScale()
|
|
|
|
{
|
2013-12-17 21:54:06 +01:00
|
|
|
return Math.min(1, (gasStored == null || getCapacity() == 0 ? 0 : (float)gasStored.amount/getCapacity()));
|
2013-12-14 21:30:41 +01:00
|
|
|
}
|
|
|
|
|
2013-06-26 23:49:47 +02:00
|
|
|
@Override
|
|
|
|
public String toString()
|
|
|
|
{
|
2013-08-17 19:32:05 +02:00
|
|
|
return "[GasNetwork] " + transmitters.size() + " transmitters, " + possibleAcceptors.size() + " acceptors.";
|
2013-06-26 23:49:47 +02:00
|
|
|
}
|
2013-08-22 17:36:31 +02:00
|
|
|
|
2013-12-18 02:28:25 +01:00
|
|
|
@Override
|
|
|
|
public boolean canMerge(List<ITransmitterNetwork<?, ?>> networks)
|
|
|
|
{
|
|
|
|
Gas found = null;
|
|
|
|
|
|
|
|
for(ITransmitterNetwork<?, ?> network : networks)
|
|
|
|
{
|
2014-01-03 03:58:14 +01:00
|
|
|
if(network instanceof GasNetwork)
|
2013-12-18 02:28:25 +01:00
|
|
|
{
|
|
|
|
GasNetwork net = (GasNetwork)network;
|
|
|
|
|
|
|
|
if(net.gasStored != null)
|
|
|
|
{
|
|
|
|
if(found != null && found != net.gasStored.getGas())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
found = net.gasStored.getGas();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-22 17:36:31 +02:00
|
|
|
@Override
|
2013-12-21 01:12:33 +01:00
|
|
|
protected GasNetwork create(IGridTransmitter<GasNetwork>... varTransmitters)
|
2013-08-22 17:36:31 +02:00
|
|
|
{
|
2013-11-29 03:43:53 +01:00
|
|
|
GasNetwork network = new GasNetwork(varTransmitters);
|
2013-12-18 02:28:25 +01:00
|
|
|
network.refGas = refGas;
|
2013-12-17 18:53:33 +01:00
|
|
|
|
|
|
|
if(gasStored != null)
|
|
|
|
{
|
|
|
|
if(network.gasStored == null)
|
|
|
|
{
|
|
|
|
network.gasStored = gasStored;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
network.gasStored.amount += gasStored.amount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-18 17:19:30 +01:00
|
|
|
network.gasScale = network.getScale();
|
2013-12-18 02:42:52 +01:00
|
|
|
gasScale = 0;
|
|
|
|
refGas = null;
|
|
|
|
gasStored = null;
|
|
|
|
|
2013-11-29 03:43:53 +01:00
|
|
|
return network;
|
2013-08-22 17:36:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-12-21 01:12:33 +01:00
|
|
|
protected GasNetwork create(Collection<IGridTransmitter<GasNetwork>> collection)
|
2013-08-22 17:36:31 +02:00
|
|
|
{
|
2013-11-29 03:43:53 +01:00
|
|
|
GasNetwork network = new GasNetwork(collection);
|
2013-12-18 02:28:25 +01:00
|
|
|
network.refGas = refGas;
|
2013-12-17 18:53:33 +01:00
|
|
|
|
|
|
|
if(gasStored != null)
|
|
|
|
{
|
|
|
|
if(network.gasStored == null)
|
|
|
|
{
|
|
|
|
network.gasStored = gasStored;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
network.gasStored.amount += gasStored.amount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-18 17:19:30 +01:00
|
|
|
network.gasScale = network.getScale();
|
|
|
|
|
2013-11-29 03:43:53 +01:00
|
|
|
return network;
|
2013-08-22 17:36:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected GasNetwork create(Set<GasNetwork> networks)
|
|
|
|
{
|
2013-12-17 18:53:33 +01:00
|
|
|
return new GasNetwork(networks);
|
2013-08-22 17:36:31 +02:00
|
|
|
}
|
2013-08-22 20:07:28 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TransmissionType getTransmissionType()
|
|
|
|
{
|
|
|
|
return TransmissionType.GAS;
|
|
|
|
}
|
2013-08-23 20:23:08 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getNeeded()
|
|
|
|
{
|
2013-12-14 06:36:52 +01:00
|
|
|
return Integer.toString(getGasNeeded());
|
2013-08-23 20:23:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getFlow()
|
|
|
|
{
|
2013-12-14 06:36:52 +01:00
|
|
|
return gasStored != null ? gasStored.getGas().getLocalizedName() + " (" + gasStored.amount + ")" : "None";
|
2013-08-23 20:23:08 +02:00
|
|
|
}
|
2013-06-26 23:49:47 +02:00
|
|
|
}
|