Removed Extra Grids Based on API Change.

This commit is contained in:
AlgorithmX2 2014-02-04 10:11:29 -06:00
parent dc754b4989
commit aed1c9b82c
9 changed files with 52 additions and 44 deletions

View file

@ -64,7 +64,7 @@ public class Grid implements IGrid
public void remove(GridNode gridNode) public void remove(GridNode gridNode)
{ {
for (IGridCache c : caches.values()) for (IGridCache c : caches.values())
c.removeNode( this, gridNode, gridNode.getMachine() ); c.removeNode( gridNode, gridNode.getMachine() );
Collection<IGridNode> nodes = Machines.get( gridNode.getMachineClass() ); Collection<IGridNode> nodes = Machines.get( gridNode.getMachineClass() );
if ( nodes != null ) if ( nodes != null )
@ -143,7 +143,7 @@ public class Grid implements IGrid
nodes.add( gridNode ); nodes.add( gridNode );
for (IGridCache c : caches.values()) for (IGridCache c : caches.values())
c.addNode( this, gridNode, gridNode.getMachine() ); c.addNode( gridNode, gridNode.getMachine() );
gridNode.gridProxy.gridChanged(); gridNode.gridProxy.gridChanged();
// postEventTo( gridNode, networkChanged ); // postEventTo( gridNode, networkChanged );
@ -198,7 +198,7 @@ public class Grid implements IGrid
{ {
for (IGridCache gc : caches.values()) for (IGridCache gc : caches.values())
{ {
gc.onUpdateTick( this ); gc.onUpdateTick();
} }
} }

View file

@ -1,6 +1,5 @@
package appeng.me; package appeng.me;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridCache; import appeng.api.networking.IGridCache;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
@ -18,21 +17,21 @@ public class GridCacheWrapper implements IGridCache
} }
@Override @Override
public void onUpdateTick(final IGrid grid) public void onUpdateTick()
{ {
myCache.onUpdateTick( grid ); myCache.onUpdateTick();
} }
@Override @Override
public void removeNode(final IGrid grid, final IGridNode gridNode, final IGridHost machine) public void removeNode(final IGridNode gridNode, final IGridHost machine)
{ {
myCache.removeNode( grid, gridNode, machine ); myCache.removeNode( gridNode, machine );
} }
@Override @Override
public void addNode(final IGrid grid, final IGridNode gridNode, final IGridHost machine) public void addNode(final IGridNode gridNode, final IGridHost machine)
{ {
myCache.addNode( grid, gridNode, machine ); myCache.addNode( gridNode, machine );
} }
public String getName() public String getName()

View file

@ -44,8 +44,10 @@ public class EnergyGridCache implements IEnergyGrid
double tickDrainPerTick = 0; double tickDrainPerTick = 0;
double tickInjectionPerTick = 0; double tickInjectionPerTick = 0;
// Double[] totalDrainPastTicks = new Double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; // Double[] totalDrainPastTicks = new Double[] { 0.0, 0.0, 0.0, 0.0, 0.0,
// Double[] totalInjectionPastTicks = new Double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; // 0.0, 0.0, 0.0, 0.0, 0.0 };
// Double[] totalInjectionPastTicks = new Double[] { 0.0, 0.0, 0.0, 0.0,
// 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
/** /**
* power status * power status
@ -194,7 +196,7 @@ public class EnergyGridCache implements IEnergyGrid
} }
@Override @Override
public void addNode(IGrid grid, IGridNode node, IGridHost machine) public void addNode(IGridNode node, IGridHost machine)
{ {
if ( machine instanceof IEnergyGridProvider ) if ( machine instanceof IEnergyGridProvider )
gproviders.add( (IEnergyGridProvider) machine ); gproviders.add( (IEnergyGridProvider) machine );
@ -225,11 +227,11 @@ public class EnergyGridCache implements IEnergyGrid
} }
} }
grid.postEventTo( node, new MENetworkPowerStatusChange() ); myGrid.postEventTo( node, new MENetworkPowerStatusChange() );
} }
@Override @Override
public void removeNode(IGrid grid, IGridNode node, IGridHost machine) public void removeNode(IGridNode node, IGridHost machine)
{ {
if ( machine instanceof IEnergyGridProvider ) if ( machine instanceof IEnergyGridProvider )
gproviders.remove( machine ); gproviders.remove( machine );
@ -257,7 +259,7 @@ public class EnergyGridCache implements IEnergyGrid
} }
@Override @Override
public void onUpdateTick(IGrid grid) public void onUpdateTick()
{ {
avgDrainPerTick *= (AvgLength - 1) / AvgLength; avgDrainPerTick *= (AvgLength - 1) / AvgLength;
avgInjectionPerTick *= (AvgLength - 1) / AvgLength; avgInjectionPerTick *= (AvgLength - 1) / AvgLength;
@ -292,9 +294,9 @@ public class EnergyGridCache implements IEnergyGrid
// update public status, this buffers power ups for 30 ticks. // update public status, this buffers power ups for 30 ticks.
if ( hasPower && ticksSinceHasPowerChange > 30 ) if ( hasPower && ticksSinceHasPowerChange > 30 )
publicPowerState( true, grid ); publicPowerState( true, myGrid );
else if ( !hasPower ) else if ( !hasPower )
publicPowerState( false, grid ); publicPowerState( false, myGrid );
availableTicksSinceUpdate++; availableTicksSinceUpdate++;
if ( extra > 32 ) if ( extra > 32 )
@ -433,7 +435,8 @@ public class EnergyGridCache implements IEnergyGrid
return avgDrainPerTick;/* return avgDrainPerTick;/*
* double out = 0; * double out = 0;
* *
* for (double x : totalDrainPastTicks) out += x; * for (double x : totalDrainPastTicks) out +=
* x;
* *
* return out / totalDrainPastTicks.length; * return out / totalDrainPastTicks.length;
*/ */
@ -445,9 +448,11 @@ public class EnergyGridCache implements IEnergyGrid
return avgInjectionPerTick;/* return avgInjectionPerTick;/*
* double out = 0; * double out = 0;
* *
* for (double x : totalInjectionPastTicks) out += x; * for (double x : totalInjectionPastTicks)
* out += x;
* *
* return out / totalInjectionPastTicks.length; * return out /
* totalInjectionPastTicks.length;
*/ */
} }

View file

@ -51,14 +51,14 @@ public class GridStorageCache implements IStorageGrid
} }
@Override @Override
public void onUpdateTick(IGrid grid) public void onUpdateTick()
{ {
itemMonitor.onTick(); itemMonitor.onTick();
fluidMonitor.onTick(); fluidMonitor.onTick();
} }
@Override @Override
public void removeNode(IGrid grid, IGridNode node, IGridHost machine) public void removeNode(IGridNode node, IGridHost machine)
{ {
if ( machine instanceof ICellContainer ) if ( machine instanceof ICellContainer )
{ {
@ -90,7 +90,7 @@ public class GridStorageCache implements IStorageGrid
} }
@Override @Override
public void addNode(IGrid grid, IGridNode node, IGridHost machine) public void addNode(IGridNode node, IGridHost machine)
{ {
if ( machine instanceof ICellContainer ) if ( machine instanceof ICellContainer )
{ {

View file

@ -55,7 +55,7 @@ public class P2PCache implements IGridCache
} }
@Override @Override
public void onUpdateTick(IGrid grid) public void onUpdateTick()
{ {
} }
@ -72,13 +72,14 @@ public class P2PCache implements IGridCache
else else
inputs.put( t.freq, t ); inputs.put( t.freq, t );
// AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq ); // AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq
// );
updateTunnel( t.freq, t.output ); updateTunnel( t.freq, t.output );
updateTunnel( t.freq, !t.output ); updateTunnel( t.freq, !t.output );
} }
@Override @Override
public void addNode(IGrid grid, IGridNode node, IGridHost machine) public void addNode(IGridNode node, IGridHost machine)
{ {
if ( machine instanceof PartP2PTunnel ) if ( machine instanceof PartP2PTunnel )
{ {
@ -89,7 +90,8 @@ public class P2PCache implements IGridCache
} }
PartP2PTunnel t = (PartP2PTunnel) machine; PartP2PTunnel t = (PartP2PTunnel) machine;
// AELog.info( "add-" + (t.output ? "output: " : "input: ") + t.freq ); // AELog.info( "add-" + (t.output ? "output: " : "input: ") + t.freq
// );
if ( t.output ) if ( t.output )
outputs.put( t.freq, t ); outputs.put( t.freq, t );
@ -101,7 +103,7 @@ public class P2PCache implements IGridCache
} }
@Override @Override
public void removeNode(IGrid grid, IGridNode node, IGridHost machine) public void removeNode(IGridNode node, IGridHost machine)
{ {
if ( machine instanceof PartP2PTunnel ) if ( machine instanceof PartP2PTunnel )
{ {
@ -112,7 +114,8 @@ public class P2PCache implements IGridCache
} }
PartP2PTunnel t = (PartP2PTunnel) machine; PartP2PTunnel t = (PartP2PTunnel) machine;
// AELog.info( "rmv-" + (t.output ? "output: " : "input: ") + t.freq ); // AELog.info( "rmv-" + (t.output ? "output: " : "input: ") + t.freq
// );
if ( t.output ) if ( t.output )
outputs.remove( t.freq, t ); outputs.remove( t.freq, t );

View file

@ -55,7 +55,7 @@ public class PathGridCache implements IPathingGrid
} }
@Override @Override
public void onUpdateTick(IGrid grid) public void onUpdateTick()
{ {
if ( recalculateControllerNextTick ) if ( recalculateControllerNextTick )
{ {
@ -95,8 +95,9 @@ public class PathGridCache implements IPathingGrid
closedList = new HashSet(); closedList = new HashSet();
semiOpen = new HashSet(); semiOpen = new HashSet();
// myGrid.getPivot().beginVisition( new AdHocChannelUpdater( 0 ) ); // myGrid.getPivot().beginVisition( new AdHocChannelUpdater( 0 )
for (IGridNode node : grid.getMachines( TileController.class )) // );
for (IGridNode node : myGrid.getMachines( TileController.class ))
{ {
closedList.add( (IPathItem) node ); closedList.add( (IPathItem) node );
for (IGridConnection gcc : node.getConnections()) for (IGridConnection gcc : node.getConnections())
@ -182,7 +183,7 @@ public class PathGridCache implements IPathingGrid
} }
@Override @Override
public void removeNode(IGrid grid, IGridNode gridNode, IGridHost machine) public void removeNode(IGridNode gridNode, IGridHost machine)
{ {
if ( machine instanceof TileController ) if ( machine instanceof TileController )
{ {
@ -197,7 +198,7 @@ public class PathGridCache implements IPathingGrid
} }
@Override @Override
public void addNode(IGrid grid, IGridNode gridNode, IGridHost machine) public void addNode(IGridNode gridNode, IGridHost machine)
{ {
if ( machine instanceof TileController ) if ( machine instanceof TileController )
{ {

View file

@ -97,7 +97,7 @@ public class SecurityCache implements IGridCache, ISecurityGrid
} }
@Override @Override
public void removeNode(IGrid grid, IGridNode gridNode, IGridHost machine) public void removeNode(IGridNode gridNode, IGridHost machine)
{ {
if ( machine instanceof TileSecurity ) if ( machine instanceof TileSecurity )
{ {
@ -107,7 +107,7 @@ public class SecurityCache implements IGridCache, ISecurityGrid
} }
@Override @Override
public void addNode(IGrid grid, IGridNode gridNode, IGridHost machine) public void addNode(IGridNode gridNode, IGridHost machine)
{ {
if ( machine instanceof TileSecurity ) if ( machine instanceof TileSecurity )
{ {
@ -119,7 +119,7 @@ public class SecurityCache implements IGridCache, ISecurityGrid
} }
@Override @Override
public void onUpdateTick(IGrid grid) public void onUpdateTick()
{ {
} }

View file

@ -182,18 +182,18 @@ public class SpatialPylonCache implements IGridCache, ISpatialCache
} }
@Override @Override
public void onUpdateTick(IGrid grid) public void onUpdateTick()
{ {
} }
@Override @Override
public void addNode(IGrid grid, IGridNode node, IGridHost machine) public void addNode(IGridNode node, IGridHost machine)
{ {
} }
@Override @Override
public void removeNode(IGrid grid, IGridNode node, IGridHost machine) public void removeNode(IGridNode node, IGridHost machine)
{ {
} }

View file

@ -52,7 +52,7 @@ public class TickManagerCache implements ITickManager
} }
@Override @Override
public void onUpdateTick(IGrid grid) public void onUpdateTick()
{ {
currentTick++; currentTick++;
while (!upcomingTicks.isEmpty()) while (!upcomingTicks.isEmpty())
@ -146,7 +146,7 @@ public class TickManagerCache implements ITickManager
} }
@Override @Override
public void removeNode(IGrid grid, IGridNode gridNode, IGridHost machine) public void removeNode(IGridNode gridNode, IGridHost machine)
{ {
if ( machine instanceof IGridTickable ) if ( machine instanceof IGridTickable )
{ {
@ -157,7 +157,7 @@ public class TickManagerCache implements ITickManager
} }
@Override @Override
public void addNode(IGrid grid, IGridNode gridNode, IGridHost machine) public void addNode(IGridNode gridNode, IGridHost machine)
{ {
if ( machine instanceof IGridTickable ) if ( machine instanceof IGridTickable )
{ {