Re-added pipe network connection map

This commit is contained in:
DarkGuardsman 2014-01-14 15:25:19 -05:00
parent 95ce03ee48
commit 06dd77d2cc
3 changed files with 72 additions and 11 deletions

View file

@ -28,7 +28,6 @@ public class FluidNetwork extends Network<IFluidNetwork, IFluidPart, IFluidHandl
@Override
public void reconstruct()
{
System.out.println("Rebuilding network");
if (this.reloadTanks)
{
this.reloadTanks();
@ -81,7 +80,6 @@ public class FluidNetwork extends Network<IFluidNetwork, IFluidPart, IFluidHandl
@Override
public int fill(IFluidPart source, ForgeDirection from, FluidStack resource, boolean doFill)
{
System.out.println("Filling network tank");
int prev = this.getTank().getFluidAmount();
int fill = this.getTank().fill(resource, doFill);
if (prev != this.getTank().getFluid().amount)
@ -94,7 +92,6 @@ public class FluidNetwork extends Network<IFluidNetwork, IFluidPart, IFluidHandl
@Override
public FluidStack drain(IFluidPart source, ForgeDirection from, FluidStack resource, boolean doDrain)
{
System.out.println("Draining network tank");
if (resource != null && resource.isFluidEqual(this.getTank().getFluid()))
{
FluidStack before = this.getTank().getFluid();
@ -149,7 +146,6 @@ public class FluidNetwork extends Network<IFluidNetwork, IFluidPart, IFluidHandl
public void reloadTanks()
{
this.reloadTanks = false;
System.out.println("Reloading fluids");
FluidStack stack = this.getTank().getFluid();
if (stack != null)

View file

@ -1,10 +1,79 @@
package resonantinduction.mechanical.fluid.pipe;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.api.fluid.IFluidPart;
import resonantinduction.mechanical.fluid.network.FluidNetwork;
/** @author DarkGuardsman */
public class PipeNetwork extends FluidNetwork
{
//TODO implements pressure for future hydraulic machines
public HashMap<IFluidHandler, EnumSet<ForgeDirection>> connectionMap = new HashMap<IFluidHandler, EnumSet<ForgeDirection>>();
@Override
public void update()
{
//Slight delay to allow visual effect to take place before draining the pipe tanks
if (this.ticks % 3 == 0)
{
//TODO find a home for all fluid stored
//TODO limit input per machine by pipe connected
}
}
@Override
public boolean canUpdate()
{
return super.canUpdate() || this.getTank().getFluid() != null;
}
@Override
public boolean continueUpdate()
{
return super.canUpdate() || this.getTank().getFluid() != null;
}
@Override
public void reconstruct()
{
this.connectionMap.clear();
super.reconstruct();
}
@Override
public void buildPart(IFluidPart part)
{
super.buildPart(part);
for (int i = 0; i < 6; i++)
{
if (part.getConnections()[i] instanceof IFluidHandler)
{
EnumSet<ForgeDirection> set = this.connectionMap.get(part.getConnections()[i]);
if (set == null)
{
set = EnumSet.noneOf(ForgeDirection.class);
}
set.add(ForgeDirection.getOrientation(i).getOpposite());
this.connectionMap.put((IFluidHandler) part.getConnections()[i], set);
}
}
}
@Override
public FluidStack drain(IFluidPart source, ForgeDirection from, FluidStack resource, boolean doDrain)
{
return null;
}
@Override
public FluidStack drain(IFluidPart source, ForgeDirection from, int resource, boolean doDrain)
{
return null;
}
}

View file

@ -1,13 +1,9 @@
package resonantinduction.mechanical.network;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.api.CompatibilityModule;
import universalelectricity.api.energy.IConductor;
import universalelectricity.api.net.IConnector;
import universalelectricity.core.net.ConnectionPathfinder;
import universalelectricity.core.net.Network;
@ -21,7 +17,7 @@ public class MechNetwork extends Network<IMechNetwork, IMechConnector, IMechMach
private int force = 0;
private int speed = 0;
private int resistance = 0;
private HashMap<IMechMachine, ForceWrapper[]> forceMap = new HashMap<IMechMachine, ForceWrapper[]>();
@Override