Some work on MechanicalGrid

This commit is contained in:
Calclavia 2014-11-18 22:35:54 +08:00
parent 01fb063238
commit 972bd7ae9c
4 changed files with 11 additions and 8 deletions

View file

@ -41,8 +41,8 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
if (getMultiBlock.isPrimary)
UpdateTicker.world.enqueue(() => if (world != null) sendPacket(1))
if (mechanicalNode.angularVelocity == 0)
UpdateTicker.world.enqueue(() => if (world != null) sendPacket(2))
// if (mechanicalNode.angularVelocity == 0)
// UpdateTicker.world.enqueue(() => if (world != null) sendPacket(2))
}
mechanicalNode.onGridReconstruct = () => if (world != null && !world.isRemote) sendPacket(2)
@ -89,9 +89,9 @@ class PartGear extends PartMechanical with IMultiBlockStructure[PartGear]
return super.activate(player, hit, itemStack)
}
override def preRemove
override def preRemove()
{
super.preRemove
super.preRemove()
getMultiBlock.deconstruct()
}

View file

@ -70,14 +70,14 @@ class MechanicalGrid extends GridNode[NodeMechanical](classOf[NodeMechanical]) w
val angularAcceleration = deltaTorque / n.momentOfInertia
n._angularVelocity = angularAcceleration * deltaTime * inversion
if (Math.abs(n.torque - prevTorque) >= 0.1)
if (Math.abs(n.torque - prevTorque) > 0)
n.onTorqueChanged()
if (Math.abs(n.angularVelocity - prevAngularVelocity) >= 0.01)
if (Math.abs(n.angularVelocity - prevAngularVelocity) > 0)
n.onVelocityChanged()
//Clear buffers
n.bufferTorque = 0
n.bufferTorque = n.bufferDefaultTorque
})
}
}

View file

@ -39,6 +39,7 @@ class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](par
* Buffer values used by the grid to transfer mechanical energy.
*/
protected[grid] var bufferTorque = 0D
var bufferDefaultTorque = 0D
/**
* Angle calculations
@ -83,4 +84,6 @@ class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](par
override def newGrid: GridNode[NodeMechanical] = new MechanicalGrid
override def isValidConnection(other: AnyRef): Boolean = other.isInstanceOf[NodeMechanical]
override def toString = "NodeMechanical[Connections: "+connections.size() + " Torque: " + torque + " Angular Velocity:" + angularVelocity+"]"
}

View file

@ -64,7 +64,7 @@ class TileWindTurbine extends TileTurbine with IBoilHandler
computePower()
}
getMultiBlock.get.mechanicalNode.rotate(windTorque)
getMultiBlock.get.mechanicalNode.bufferDefaultTorque = windTorque
}
else
{