electrodynamics/archive/java/resonantinduction/old/transport/NetworkAssembly.java
2014-01-11 17:44:07 +08:00

51 lines
1.3 KiB
Java

package resonantinduction.old.transport;
import resonantinduction.core.tilenetwork.INetworkPart;
import resonantinduction.core.tilenetwork.prefab.NetworkSharedPower;
import resonantinduction.core.tilenetwork.prefab.NetworkUpdateHandler;
public class NetworkAssembly extends NetworkSharedPower
{
private long networkPartEnergyRequest = 0;
private long lastUpdateTime = 0;
static
{
NetworkUpdateHandler.registerNetworkClass("AssemblyNet", NetworkAssembly.class);
}
public NetworkAssembly()
{
super();
}
public NetworkAssembly(INetworkPart... parts)
{
super(parts);
}
/** Gets the demand of all parts of the network including network parts */
public float getNetworkDemand()
{
if (System.currentTimeMillis() - this.lastUpdateTime > 100)
{
this.networkPartEnergyRequest = 0;
this.lastUpdateTime = System.currentTimeMillis();
for (INetworkPart part : this.getMembers())
{
if (part instanceof TileEntityAssembly)
{
networkPartEnergyRequest += ((TileEntityAssembly) part).getWattLoad();
networkPartEnergyRequest += ((TileEntityAssembly) part).getExtraLoad();
}
}
}
return networkPartEnergyRequest;
}
@Override
public boolean isValidMember(INetworkPart part)
{
return super.isValidMember(part) && part instanceof TileEntityAssembly;
}
}