Minor adjustment to make certain routes preferred over others.

This commit is contained in:
AlgorithmX2
2014-07-13 15:45:00 -05:00
parent 094d632a2c
commit 5c098544f2
3 changed files with 19 additions and 1 deletions
+17
View File
@@ -1,5 +1,7 @@
package appeng.me;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.LinkedList;
import java.util.List;
@@ -354,6 +356,21 @@ public class GridNode implements IGridNode, IPathItem
Connections.add( gridConnection );
if ( gridConnection.hasDirection() )
gridProxy.onGridNotification( GridNotification.ConnectionsChanged );
final IGridNode gn = this;
Collections.sort( Connections, new Comparator<IGridConnection>() {
@Override
public int compare(IGridConnection o1, IGridConnection o2)
{
boolean preferedA = o1.getOtherSide( gn ).hasFlag( GridFlags.PREFERED );
boolean preferedB = o2.getOtherSide( gn ).hasFlag( GridFlags.PREFERED );
return preferedA == preferedB ? 0 : (preferedA ? -1 : 1);
}
} );
}
public void removeConnection(IGridConnection gridConnection)
+1
View File
@@ -52,6 +52,7 @@ public class PartCable extends AEBasePart implements IPartCable
public PartCable(Class c, ItemStack is) {
super( c, is );
proxy.setFlags( GridFlags.PREFERED );
proxy.setIdlePowerUsage( 0.0 );
proxy.myColor = AEColor.values()[((ItemMultiPart) is.getItem()).varientOf( is.getItemDamage() )];
}
+1 -1
View File
@@ -56,7 +56,7 @@ public class PartDenseCable extends PartCable
public PartDenseCable(Class c, ItemStack is) {
super( c, is );
proxy.setFlags( GridFlags.TIER_2_CAPACITY );
proxy.setFlags( GridFlags.TIER_2_CAPACITY, GridFlags.PREFERED );
}
public PartDenseCable(ItemStack is) {