electrodynamics/src/main/scala/edx/mechanical/mech/turbine/NodeTurbine.scala

50 lines
1.4 KiB
Scala
Raw Normal View History

2015-01-14 12:06:03 +01:00
package edx.mechanical.mech.turbine
2015-01-14 12:06:03 +01:00
import edx.core.interfaces.TNodeMechanical
import edx.mechanical.mech.grid.NodeMechanical
import net.minecraftforge.common.util.ForgeDirection
/**
* Turbine's Mechanical node
* Turbines always face forward and connect from behind.
*
* @author Calclavia, Darkguardsman
*/
class NodeTurbine(parent: TileTurbine) extends NodeMechanical(parent)
{
/**
* The mechanical load
* @return Torque in Newton meters per second
*/
override def inertia = 100 * parent.multiBlockRadius * parent.multiBlockRadius
/**
* 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
}