Adjusted wind turbine power

This commit is contained in:
Calclavia 2014-11-22 21:52:45 +08:00
parent c6e4437199
commit fcbab8cb3b
7 changed files with 24 additions and 21 deletions

View file

@ -25,8 +25,8 @@ trait TNodeMechanical extends INode with IVectorWorld
def torque: Double
/**
* The mechanical load
* @return Energy loss in joules
* The mechanical load energy loss per second.
* @return Power loss in Watts.
*/
def getLoad = 10D

View file

@ -59,6 +59,9 @@ abstract class TileMechanical(material: Material) extends SpatialTile(material:
override def use(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
{
if (!world.isRemote)
println(mechanicalNode)
//Debugging
val itemStack: ItemStack = player.getHeldItem

View file

@ -84,9 +84,9 @@ class MechanicalGrid extends GridNode[NodeMechanical](classOf[NodeMechanical]) w
{
//Calculate energy loss
val power = torque * angularVelocity
val netPower = power - load
val netTorque = netPower * (torque / power)
val netVelocity = netPower * (angularVelocity / power)
val netEnergy = power - load * deltaTime
val netTorque = netEnergy * (torque / power)
val netVelocity = netEnergy * (angularVelocity / power)
curr._torque += netTorque
curr._angularVelocity += netVelocity * deltaTime

View file

@ -2,7 +2,7 @@ package resonantinduction.mechanical.mech.grid
import resonant.api.grid.INodeProvider
import resonant.lib.grid.GridNode
import resonant.lib.grid.node.NodeGrid
import resonant.lib.grid.node.{NodeGrid, TTileConnector}
import resonant.lib.transform.vector.IVectorWorld
import resonantinduction.core.interfaces.TNodeMechanical
import resonantinduction.core.prefab.node.TMultipartNode
@ -15,7 +15,7 @@ import scala.collection.convert.wrapAll._
*
* @author Calclavia, Darkguardsman
*/
class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](parent) with TMultipartNode[NodeMechanical] with TNodeMechanical with IVectorWorld
class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](parent) with TTileConnector[NodeMechanical] with TMultipartNode[NodeMechanical] with TNodeMechanical with IVectorWorld
{
protected[grid] var _torque = 0D
protected[grid] var _angularVelocity = 0D
@ -85,7 +85,7 @@ class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](par
n =>
{
val diff = Math.round((n.prevAngle - prevAngle) * angleDisplacement)
n.prevAngle = (prevAngle + diff) % (Math.PI * 2)
n.prevAngle = (prevAngle + angleDisplacement) % (Math.PI * 2)
}
)
prevTime = System.currentTimeMillis()
@ -105,5 +105,10 @@ class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](par
override def isValidConnection(other: AnyRef): Boolean = other.isInstanceOf[NodeMechanical]
/**
* The class used to compare when making connections
*/
override protected def getCompareClass = classOf[NodeMechanical]
override def toString = "NodeMechanical[Connections: " + connections.size() + " Torque: " + torque + " Angular Velocity:" + angularVelocity + "]"
}

View file

@ -17,22 +17,19 @@ class NodeTurbine(parent: TileTurbine) extends NodeMechanical(parent)
* The mechanical load
* @return Torque in Newton meters per second
*/
override def getLoad = 100d
override def getLoad = 100 * parent.multiBlockRadius * parent.multiBlockRadius
/**
* Moment of inertia = m * r * r
* Where "m" is the mass and "r" is the radius of the object.
*/
override def radius(other: TNodeMechanical) = parent.multiBlockRadius * parent.multiBlockRadius
override def radius(other: TNodeMechanical) = parent.multiBlockRadius
def turbine: TileTurbine =
{
return getParent.asInstanceOf[TileTurbine]
}
def turbine: TileTurbine = getParent.asInstanceOf[TileTurbine]
override def canConnect[B](other: B, from: ForgeDirection): Boolean =
{
return turbine.getMultiBlock.isPrimary && other.isInstanceOf[NodeMechanical] && !(other.isInstanceOf[NodeTurbine]) && from == turbine.getDirection
return turbine.getMultiBlock.isPrimary && other.isInstanceOf[NodeMechanical] && !other.isInstanceOf[NodeTurbine] && from == turbine.getDirection
}
/**

View file

@ -121,7 +121,7 @@ class TileTurbine extends TileMechanical(Material.wood) with IMultiBlockStructur
return multiBlock
}
def onMultiBlockChanged
def onMultiBlockChanged()
{
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, if (getBlockType != null) getBlockType else null)
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)

View file

@ -60,11 +60,9 @@ class TileWindTurbine extends TileTurbine with IBoilHandler
{
//This is a vertical wind turbine
if (ticks % 20 == 0)
{
computePower()
}
getMultiBlock.get.mechanicalNode.rotate(windPower * multiBlockRadius, windPower / multiBlockRadius)
getMultiBlock.get.mechanicalNode.rotate(windPower * multiBlockRadius / 20, windPower / multiBlockRadius / 20)
}
else
{
@ -111,7 +109,7 @@ class TileWindTurbine extends TileTurbine with IBoilHandler
efficiency = efficiency - openBlockCache(checkCount) + openAirBlocks
openBlockCache(checkCount) = openAirBlocks.toByte
checkCount = (checkCount + 1) % (openBlockCache.length - 1)
val multiblockMultiplier = (multiBlockRadius + 0.5f) * 2
val multiblockMultiplier = multiBlockRadius + 0.5f
val materialMultiplier = tier match
{
@ -122,7 +120,7 @@ class TileWindTurbine extends TileTurbine with IBoilHandler
val biome = worldObj.getBiomeGenForCoords(xCoord, zCoord)
val hasBonus = biome.isInstanceOf[BiomeGenOcean] || biome.isInstanceOf[BiomeGenPlains] || biome == BiomeGenBase.river
val windSpeed = (worldObj.rand.nextFloat / 8) + (yCoord / 256f) * (if (hasBonus) 1.2f else 1) + worldObj.getRainStrength(1.5f)
val windSpeed = (worldObj.rand.nextFloat / 5) + (yCoord / 256f) * (if (hasBonus) 1.2f else 1) + worldObj.getRainStrength(0.5f)
windPower = materialMultiplier * multiblockMultiplier * windSpeed * efficiency * Settings.WIND_POWER_RATIO / 20
}