From 3cf6752ec5391b2306787d0979b2b334c5312a1c Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sun, 18 Jan 2015 09:58:31 +0800 Subject: [PATCH] Rewrote Grid base class --- ...hanicalGrid.scala => GridMechanical.scala} | 4 +- .../mechanical/mech/grid/NodeMechanical.scala | 38 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) rename src/main/scala/edx/mechanical/mech/grid/{MechanicalGrid.scala => GridMechanical.scala} (97%) diff --git a/src/main/scala/edx/mechanical/mech/grid/MechanicalGrid.scala b/src/main/scala/edx/mechanical/mech/grid/GridMechanical.scala similarity index 97% rename from src/main/scala/edx/mechanical/mech/grid/MechanicalGrid.scala rename to src/main/scala/edx/mechanical/mech/grid/GridMechanical.scala index 82e637d7d..593458788 100644 --- a/src/main/scala/edx/mechanical/mech/grid/MechanicalGrid.scala +++ b/src/main/scala/edx/mechanical/mech/grid/GridMechanical.scala @@ -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 } diff --git a/src/main/scala/edx/mechanical/mech/grid/NodeMechanical.scala b/src/main/scala/edx/mechanical/mech/grid/NodeMechanical.scala index 520968bce..2e2bc3050 100644 --- a/src/main/scala/edx/mechanical/mech/grid/NodeMechanical.scala +++ b/src/main/scala/edx/mechanical/mech/grid/NodeMechanical.scala @@ -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 */