Tile Network changes

This commit is contained in:
DarkGuardsman 2013-11-08 03:03:48 -05:00
parent 801cfaed63
commit 046438c2d3
3 changed files with 15 additions and 35 deletions

View file

@ -12,6 +12,7 @@ import universalelectricity.core.block.IElectricalStorage;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
import dark.api.parts.INetworkEnergyPart; import dark.api.parts.INetworkEnergyPart;
import dark.api.parts.INetworkPart; import dark.api.parts.INetworkPart;
import dark.core.prefab.tilenetwork.NetworkHandler;
import dark.core.prefab.tilenetwork.NetworkSharedPower; import dark.core.prefab.tilenetwork.NetworkSharedPower;
public class NetworkAssembly extends NetworkSharedPower public class NetworkAssembly extends NetworkSharedPower
@ -38,18 +39,16 @@ public class NetworkAssembly extends NetworkSharedPower
public float maxDemand = 0; public float maxDemand = 0;
/** lowest demand the network has seen */ /** lowest demand the network has seen */
public float minDemand = 0; public float minDemand = 0;
static
{
NetworkHandler.registerNetworkClass("AssemblyNet", NetworkAssembly.class);
}
public NetworkAssembly(INetworkPart... parts) public NetworkAssembly(INetworkPart... parts)
{ {
super(parts); super(parts);
} }
@Override
public NetworkAssembly newInstance()
{
return new NetworkAssembly();
}
/** Gets the demand of all parts of the network including network parts */ /** Gets the demand of all parts of the network including network parts */
public float getNetworkDemand() public float getNetworkDemand()
{ {
@ -104,7 +103,7 @@ public class NetworkAssembly extends NetworkSharedPower
lastTime = time; lastTime = time;
} }
for (INetworkPart part : this.getNetworkMemebers()) for (INetworkPart part : this.getMembers())
{ {
if (part instanceof TileEntityAssembly) if (part instanceof TileEntityAssembly)
{ {
@ -184,17 +183,10 @@ public class NetworkAssembly extends NetworkSharedPower
return higher; return higher;
} }
@Override
public boolean isPartOfNetwork(TileEntity ent)
{
//TODO check how this is used since it might only want network parts and not connections
return this.networkMember.contains(ent);
}
@Override @Override
public boolean removeTile(TileEntity ent) public boolean removeTile(TileEntity ent)
{ {
return this.networkMember.remove(ent) || this.powerLoads.remove(ent) || this.powerSources.remove(ent); return super.removeTile(ent) || this.powerLoads.remove(ent) || this.powerSources.remove(ent);
} }
@Override @Override
@ -266,10 +258,4 @@ public class NetworkAssembly extends NetworkSharedPower
return super.isValidMember(part) && part instanceof TileEntityAssembly; return super.isValidMember(part) && part instanceof TileEntityAssembly;
} }
@Override
public String toString()
{
return "AssemblyNetwork[" + this.hashCode() + "][parts:" + this.networkMember.size() + "]";
}
} }

View file

@ -10,6 +10,7 @@ import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.electricity.ElectricityPack; import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
import dark.api.parts.INetworkEnergyPart; import dark.api.parts.INetworkEnergyPart;
import dark.api.parts.ITileNetwork;
import dark.assembly.common.AssemblyLine; import dark.assembly.common.AssemblyLine;
import dark.core.prefab.machine.TileEntityEnergyMachine; import dark.core.prefab.machine.TileEntityEnergyMachine;
import dark.core.prefab.tilenetwork.NetworkSharedPower; import dark.core.prefab.tilenetwork.NetworkSharedPower;
@ -17,7 +18,7 @@ import dark.core.prefab.tilenetwork.NetworkTileEntities;
/** A class to be inherited by all machines on the assembly line. This class acts as a single peace /** A class to be inherited by all machines on the assembly line. This class acts as a single peace
* in a network of similar tiles allowing all to share power from one or more sources * in a network of similar tiles allowing all to share power from one or more sources
* *
* @author DarkGuardsman */ * @author DarkGuardsman */
public abstract class TileEntityAssembly extends TileEntityEnergyMachine implements INetworkEnergyPart public abstract class TileEntityAssembly extends TileEntityEnergyMachine implements INetworkEnergyPart
{ {
@ -50,7 +51,7 @@ public abstract class TileEntityAssembly extends TileEntityEnergyMachine impleme
NetworkTileEntities.invalidate(this); NetworkTileEntities.invalidate(this);
if (this.getTileNetwork() != null) if (this.getTileNetwork() != null)
{ {
this.getTileNetwork().splitNetwork(this.worldObj, this); this.getTileNetwork().splitNetwork(this);
} }
super.invalidate(); super.invalidate();
} }
@ -95,7 +96,7 @@ public abstract class TileEntityAssembly extends TileEntityEnergyMachine impleme
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj); TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(dir).getTileEntity(this.worldObj);
if (tileEntity instanceof TileEntityAssembly && ((TileEntityAssembly) tileEntity).canTileConnect(Connection.NETWORK, dir.getOpposite())) if (tileEntity instanceof TileEntityAssembly && ((TileEntityAssembly) tileEntity).canTileConnect(Connection.NETWORK, dir.getOpposite()))
{ {
this.getTileNetwork().merge(((TileEntityAssembly) tileEntity).getTileNetwork(), this); this.getTileNetwork().mergeNetwork(((TileEntityAssembly) tileEntity).getTileNetwork(), this);
connectedTiles.add(tileEntity); connectedTiles.add(tileEntity);
} }
} }
@ -119,7 +120,7 @@ public abstract class TileEntityAssembly extends TileEntityEnergyMachine impleme
} }
@Override @Override
public void setTileNetwork(NetworkTileEntities network) public void setTileNetwork(ITileNetwork network)
{ {
if (network instanceof NetworkAssembly) if (network instanceof NetworkAssembly)
{ {
@ -186,13 +187,6 @@ public abstract class TileEntityAssembly extends TileEntityEnergyMachine impleme
this.energyStored = energy; this.energyStored = energy;
} }
@Override
public boolean mergeDamage(String effect)
{
this.onDisable(20);
return true;
}
@Override @Override
public AxisAlignedBB getRenderBoundingBox() public AxisAlignedBB getRenderBoundingBox()
{ {

View file

@ -23,7 +23,7 @@ import dark.core.common.DarkMain;
import dark.core.network.PacketHandler; import dark.core.network.PacketHandler;
/** Conveyer belt TileEntity that allows entities of all kinds to be moved /** Conveyer belt TileEntity that allows entities of all kinds to be moved
* *
* @author DarkGuardsman */ * @author DarkGuardsman */
public class TileEntityConveyorBelt extends TileEntityAssembly implements IBelt, IRotatable public class TileEntityConveyorBelt extends TileEntityAssembly implements IBelt, IRotatable
{ {
@ -278,12 +278,12 @@ public class TileEntityConveyorBelt extends TileEntityAssembly implements IBelt,
rear = back.getTileEntity(this.worldObj); rear = back.getTileEntity(this.worldObj);
if (front instanceof TileEntityAssembly) if (front instanceof TileEntityAssembly)
{ {
this.getTileNetwork().merge(((TileEntityAssembly) front).getTileNetwork(), this); this.getTileNetwork().mergeNetwork(((TileEntityAssembly) front).getTileNetwork(), this);
this.connectedTiles.add(front); this.connectedTiles.add(front);
} }
if (rear instanceof TileEntityAssembly) if (rear instanceof TileEntityAssembly)
{ {
this.getTileNetwork().merge(((TileEntityAssembly) rear).getTileNetwork(), this); this.getTileNetwork().mergeNetwork(((TileEntityAssembly) rear).getTileNetwork(), this);
this.connectedTiles.add(rear); this.connectedTiles.add(rear);
} }