electrodynamics/src/main/scala/edx/mechanical/fluid/transport/NodePump.scala

36 lines
985 B
Scala
Raw Normal View History

2015-01-14 12:06:03 +01:00
package edx.mechanical.fluid.transport
2015-01-14 12:06:03 +01:00
import edx.core.prefab.node.NodeFluidPressure
import net.minecraftforge.common.util.ForgeDirection
2014-11-04 15:06:08 +01:00
import net.minecraftforge.fluids.IFluidHandler
2015-01-26 12:40:32 +01:00
import resonantengine.api.tile.INodeProvider
/**
2014-11-04 15:06:08 +01:00
* A node for the pump
* @author Calclavia
*/
2014-12-10 15:28:54 +01:00
class NodePump(parent: INodeProvider) extends NodeFluidPressure(parent)
{
2014-11-06 16:11:08 +01:00
override def pressure(dir: ForgeDirection): Int =
2014-10-26 15:41:40 +01:00
{
2014-11-12 13:26:51 +01:00
if (pump.mechanicalNode.power > 0)
{
2014-11-11 15:28:25 +01:00
if (dir == pump.getDirection)
{
2014-12-10 15:28:54 +01:00
return Math.max(Math.log(Math.abs(pump.mechanicalNode.torque) + 1) * 3, 2).toInt
2014-11-11 15:28:25 +01:00
}
2014-12-10 15:28:54 +01:00
return -Math.max(Math.log(Math.abs(pump.mechanicalNode.torque) + 1) * 3, 2).toInt
}
2014-11-11 14:09:30 +01:00
2014-11-11 15:28:25 +01:00
return 0
2014-10-26 15:41:40 +01:00
}
2015-01-14 12:06:03 +01:00
def pump: TilePump = getParent.asInstanceOf[TilePump]
2014-11-04 15:06:08 +01:00
override def canConnect[B <: IFluidHandler](source: B, from: ForgeDirection): Boolean =
2014-10-26 15:41:40 +01:00
{
return super.canConnect(source, from) && (from == pump.getDirection || from == pump.getDirection.getOpposite)
}
}