2015-01-14 12:06:03 +01:00
|
|
|
package edx.mechanical.mech.turbine
|
2014-09-29 22:36:56 +02:00
|
|
|
|
2015-01-14 12:06:03 +01:00
|
|
|
import edx.core.interfaces.TNodeMechanical
|
|
|
|
import edx.mechanical.mech.grid.NodeMechanical
|
2014-09-29 22:36:56 +02:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Turbine's Mechanical node
|
|
|
|
* Turbines always face forward and connect from behind.
|
|
|
|
*
|
|
|
|
* @author Calclavia, Darkguardsman
|
|
|
|
*/
|
2014-11-14 17:33:22 +01:00
|
|
|
class NodeTurbine(parent: TileTurbine) extends NodeMechanical(parent)
|
2014-09-29 22:36:56 +02:00
|
|
|
{
|
|
|
|
|
2014-11-14 17:33:22 +01:00
|
|
|
/**
|
|
|
|
* The mechanical load
|
|
|
|
* @return Torque in Newton meters per second
|
|
|
|
*/
|
2015-01-22 16:10:36 +01:00
|
|
|
override def inertia = 100 * parent.multiBlockRadius * parent.multiBlockRadius
|
2014-11-14 17:33:22 +01:00
|
|
|
|
2015-01-23 12:22:17 +01:00
|
|
|
/**
|
|
|
|
* Friction is a factor that decelerates the mechanical system based on angular velocity.
|
|
|
|
*/
|
|
|
|
override def friction: Double = 3
|
|
|
|
|
2014-11-14 17:22:38 +01:00
|
|
|
/**
|
|
|
|
* Moment of inertia = m * r * r
|
|
|
|
* Where "m" is the mass and "r" is the radius of the object.
|
|
|
|
*/
|
2014-11-22 15:53:50 +01:00
|
|
|
override def radius(other: TNodeMechanical): Double =
|
|
|
|
{
|
2021-04-05 14:41:30 +02:00
|
|
|
val deltaPos = other.asInstanceOf[NodeMechanical].toVectorWorld - toVectorWorld
|
2014-11-22 15:53:50 +01:00
|
|
|
|
|
|
|
if (deltaPos.normalize.toForgeDirection == parent.getDirection)
|
|
|
|
return super.radius(other)
|
|
|
|
|
|
|
|
return parent.multiBlockRadius
|
|
|
|
}
|
2014-11-14 17:22:38 +01:00
|
|
|
|
2014-11-22 15:53:50 +01:00
|
|
|
override def canConnect[B <: NodeMechanical](other: B, from: ForgeDirection): Boolean =
|
2014-10-26 15:41:40 +01:00
|
|
|
{
|
2014-11-26 16:13:24 +01:00
|
|
|
return turbine.getMultiBlock.isPrimary && other.isInstanceOf[NodeMechanical] && !other.isInstanceOf[NodeTurbine] && canConnect(from)
|
2014-10-26 15:41:40 +01:00
|
|
|
}
|
2014-11-26 16:13:24 +01:00
|
|
|
|
|
|
|
override def canConnect(from: ForgeDirection) = from == turbine.getDirection
|
2015-01-14 12:06:03 +01:00
|
|
|
|
|
|
|
def turbine: TileTurbine = getParent.asInstanceOf[TileTurbine]
|
2021-04-05 14:41:30 +02:00
|
|
|
}
|