2014-05-09 06:10:12 +02:00
|
|
|
package appeng.me.cluster.implementations;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
2014-05-19 03:05:03 +02:00
|
|
|
import appeng.api.config.Actionable;
|
2014-05-18 05:19:23 +02:00
|
|
|
import appeng.api.networking.IGrid;
|
2014-05-09 06:10:12 +02:00
|
|
|
import appeng.api.networking.IGridHost;
|
2014-05-18 05:19:23 +02:00
|
|
|
import appeng.api.networking.IGridNode;
|
|
|
|
import appeng.api.networking.events.MENetworkCraftingCpuChange;
|
2014-05-19 03:05:03 +02:00
|
|
|
import appeng.api.networking.security.BaseActionSource;
|
|
|
|
import appeng.api.storage.data.IAEItemStack;
|
|
|
|
import appeng.api.storage.data.IAEStack;
|
2014-05-09 06:10:12 +02:00
|
|
|
import appeng.api.util.WorldCoord;
|
|
|
|
import appeng.me.cluster.IAECluster;
|
2014-05-14 04:42:14 +02:00
|
|
|
import appeng.tile.crafting.TileCraftingTile;
|
2014-05-09 06:10:12 +02:00
|
|
|
|
|
|
|
public class CraftingCPUCluster implements IAECluster
|
|
|
|
{
|
|
|
|
|
|
|
|
public WorldCoord min;
|
|
|
|
public WorldCoord max;
|
|
|
|
public boolean isDestroyed = false;
|
|
|
|
|
2014-05-14 04:42:14 +02:00
|
|
|
private LinkedList<TileCraftingTile> tiles = new LinkedList();
|
|
|
|
|
|
|
|
int accelerator = 0;
|
|
|
|
private LinkedList<TileCraftingTile> storage = new LinkedList<TileCraftingTile>();
|
|
|
|
private LinkedList<TileCraftingTile> status = new LinkedList<TileCraftingTile>();
|
2014-05-09 06:10:12 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public Iterator<IGridHost> getTiles()
|
|
|
|
{
|
2014-05-14 04:42:14 +02:00
|
|
|
return (Iterator) tiles.iterator();
|
2014-05-09 06:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public CraftingCPUCluster(WorldCoord _min, WorldCoord _max) {
|
|
|
|
min = _min;
|
|
|
|
max = _max;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateStatus(boolean updateGrid)
|
|
|
|
{
|
2014-05-14 04:42:14 +02:00
|
|
|
for (TileCraftingTile r : tiles)
|
|
|
|
{
|
|
|
|
r.updateMeta();
|
|
|
|
}
|
2014-05-09 06:10:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void destroy()
|
|
|
|
{
|
|
|
|
if ( isDestroyed )
|
|
|
|
return;
|
|
|
|
isDestroyed = true;
|
|
|
|
|
2014-05-18 05:19:23 +02:00
|
|
|
boolean posted = false;
|
|
|
|
|
2014-05-14 04:42:14 +02:00
|
|
|
for (TileCraftingTile r : tiles)
|
|
|
|
{
|
2014-05-18 05:19:23 +02:00
|
|
|
IGridNode n = r.getActionableNode();
|
|
|
|
if ( n != null && posted == false )
|
|
|
|
{
|
|
|
|
IGrid g = n.getGrid();
|
|
|
|
if ( g != null )
|
|
|
|
{
|
|
|
|
g.postEvent( new MENetworkCraftingCpuChange( n ) );
|
|
|
|
posted = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-14 04:42:14 +02:00
|
|
|
r.updateStatus( null );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addTile(TileCraftingTile te)
|
|
|
|
{
|
|
|
|
tiles.add( te );
|
|
|
|
|
|
|
|
if ( te.isStorage() )
|
|
|
|
storage.add( te );
|
|
|
|
else if ( te.isStatus() )
|
|
|
|
status.add( te );
|
|
|
|
else if ( te.isAccelerator() )
|
|
|
|
accelerator++;
|
2014-05-09 06:10:12 +02:00
|
|
|
}
|
|
|
|
|
2014-05-19 03:05:03 +02:00
|
|
|
public boolean canAccept(IAEStack input)
|
|
|
|
{
|
|
|
|
if ( input instanceof IAEItemStack )
|
|
|
|
{
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IAEStack injectItems(IAEStack input, Actionable type, BaseActionSource src)
|
|
|
|
{
|
|
|
|
if ( input instanceof IAEItemStack )
|
|
|
|
{
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
|
2014-05-09 06:10:12 +02:00
|
|
|
}
|