UpdateTicker now supports custom update rates

This commit is contained in:
Calclavia 2015-01-17 17:13:25 +08:00
parent 73a139b9e6
commit bf182141da
4 changed files with 11 additions and 19 deletions

View file

@ -139,8 +139,6 @@ class NodeFluidPressure(parent: INodeProvider, volume: Int = FluidContainerRegis
}
}
def pressure(direction: ForgeDirection): Int = _pressure
protected def updatePressure()
{
var totalPressure = 0
@ -178,6 +176,8 @@ class NodeFluidPressure(parent: INodeProvider, volume: Int = FluidContainerRegis
}
}
def pressure(direction: ForgeDirection): Int = _pressure
def pressure: Int = _pressure
def pressure_=(pressure: Int)
@ -185,7 +185,6 @@ class NodeFluidPressure(parent: INodeProvider, volume: Int = FluidContainerRegis
this._pressure = pressure
}
def canUpdate = !isInvalid && world != null
override def updateRate: Int = if (!isInvalid) 20 else 0
def continueUpdate = !isInvalid
}

View file

@ -90,7 +90,7 @@ class TileMotor extends SpatialTile(Material.iron) with TElectric with TSpatialN
//Produce mechanical energy
val mechRatio = Math.pow(10, gearRatio)
val power = dcNode.power
val negate = if (dcNode.potentialDifference > 0) 1 else -1
val negate = if (dcNode.voltage > 0) 1 else -1
mechNode.rotate(negate * power * mechRatio, negate * power / mechRatio)
//TODO: Resist DC energy
}

View file

@ -89,8 +89,11 @@ class MultimeterGrid extends Grid[PartMultimeter](classOf[PartMultimeter]) with
def update(delta: Double)
{
graphs.foreach(_.doneQueue())
doUpdate = false
if (doUpdate)
{
graphs.foreach(_.doneQueue())
doUpdate = false
}
}
def markUpdate
@ -98,15 +101,7 @@ class MultimeterGrid extends Grid[PartMultimeter](classOf[PartMultimeter]) with
doUpdate = true
}
def canUpdate: Boolean =
{
return doUpdate && continueUpdate
}
def continueUpdate: Boolean =
{
return getNodes.size > 0
}
override def updateRate: Int = if (getNodes.size > 0) 20 else 0
override def isValidNode(node: AnyRef): Boolean =
{

View file

@ -148,7 +148,5 @@ class MechanicalGrid extends GridNode[NodeMechanical](classOf[NodeMechanical]) w
}
}
override def continueUpdate = getNodes.size > 0 && !dead
override def canUpdate = getNodes.size > 0
override def updateRate: Int = if (getNodes.size > 0 && !dead) 20 else 0
}