Rewrote Grid base class

This commit is contained in:
Calclavia 2015-01-18 09:58:31 +08:00
parent 0c58b76ccb
commit 3cf6752ec5
2 changed files with 21 additions and 21 deletions

View file

@ -9,7 +9,7 @@ import scala.collection.convert.wrapAll._
* A grid that manages the mechanical objects
* @author Calclavia
*/
class MechanicalGrid extends GridNode[NodeMechanical] with IUpdate
class GridMechanical extends GridNode[NodeMechanical] with IUpdate
{
/**
* The energy loss of this grid
@ -34,7 +34,7 @@ class MechanicalGrid extends GridNode[NodeMechanical] with IUpdate
override def reconstruct(first: NodeMechanical)
{
super.reconstruct(first)
UpdateTicker.world.addUpdater(this)
UpdateTicker.threaded.addUpdater(this)
isLocked = false
}

View file

@ -51,6 +51,15 @@ class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](par
return prevAngle
}
/**
* Gets the angular velocity of the mechanical device from a specific side
*
* @return Angular velocity in meters per second
*/
override def angularVelocity = _angularVelocity
def angularVelocity_=(newVel: Double) = _angularVelocity = newVel
/**
* Sets the mechanical node's angle based on its connections
*/
@ -79,25 +88,6 @@ class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](par
def power: Double = torque * angularVelocity
def getMechanicalGrid: MechanicalGrid = super.grid.asInstanceOf[MechanicalGrid]
override def newGrid: GridNode[NodeMechanical] = new MechanicalGrid
override def isValidConnection(other: AnyRef): Boolean = other.isInstanceOf[NodeMechanical]
override def getDebugInfo = List(toString)
override def toString = "NodeMechanical [" + connections.size() + " Torque: " + BigDecimal(torque).setScale(2, BigDecimal.RoundingMode.HALF_UP) + " Velocity: " + BigDecimal(angularVelocity).setScale(2, BigDecimal.RoundingMode.HALF_UP) + "]"
/**
* Gets the angular velocity of the mechanical device from a specific side
*
* @return Angular velocity in meters per second
*/
override def angularVelocity = _angularVelocity
def angularVelocity_=(newVel: Double) = _angularVelocity = newVel
/**
* Gets the torque of the mechanical device from a specific side
*
@ -107,6 +97,16 @@ class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](par
def torque_=(newTorque: Double) = _torque = newTorque
def getMechanicalGrid: GridMechanical = super.grid.asInstanceOf[GridMechanical]
override def newGrid: GridNode[NodeMechanical] = new GridMechanical
override def isValidConnection(other: AnyRef): Boolean = other.isInstanceOf[NodeMechanical]
override def getDebugInfo = List(toString)
override def toString = "NodeMechanical [" + connections.size() + " Torque: " + BigDecimal(torque).setScale(2, BigDecimal.RoundingMode.HALF_UP) + " Velocity: " + BigDecimal(angularVelocity).setScale(2, BigDecimal.RoundingMode.HALF_UP) + "]"
/**
* The class used to compare when making connections
*/