Improved DC Grid
This commit is contained in:
parent
6ebae42295
commit
50f6dc4f28
|
@ -55,6 +55,7 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
|
|||
normalRender = false
|
||||
isOpaqueCube = false
|
||||
itemBlock = classOf[ItemBlockBattery]
|
||||
dcNode.resistance = 10
|
||||
|
||||
override def start()
|
||||
{
|
||||
|
@ -76,40 +77,13 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
|
|||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
//TODO: Voltage of battery should decrease over time.
|
||||
//TODO: Test, remove this
|
||||
if (doCharge)
|
||||
{
|
||||
dcNode.setVoltage(100)
|
||||
}
|
||||
|
||||
if (markDistributionUpdate && ticks % 5 == 0)
|
||||
{
|
||||
markDistributionUpdate = false
|
||||
}
|
||||
if (markClientUpdate && ticks % 5 == 0)
|
||||
{
|
||||
markClientUpdate = false
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord)
|
||||
}
|
||||
dcNode.setVoltage(500)
|
||||
}
|
||||
}
|
||||
|
||||
override def activate(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
super.activate(player, side, hit)
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (player.isSneaking)
|
||||
{
|
||||
doCharge = !doCharge
|
||||
println("Charge: " + doCharge)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override def write(buf: ByteBuf, id: Int)
|
||||
{
|
||||
super.write(buf, id)
|
||||
|
@ -121,7 +95,7 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
|
|||
{
|
||||
super.read(buf, id, packetType)
|
||||
energy.setEnergy(buf.readDouble())
|
||||
ioMap == buf.readShort()
|
||||
ioMap = buf.readInt()
|
||||
}
|
||||
|
||||
override def setIO(dir: ForgeDirection, packet: Int)
|
||||
|
@ -256,4 +230,20 @@ class TileBattery extends SpatialTile(Material.iron) with TIO with TElectric wit
|
|||
}
|
||||
|
||||
override def toString: String = "[TileBattery]" + x + "x " + y + "y " + z + "z "
|
||||
|
||||
override protected def use(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
|
||||
{
|
||||
super.use(player, side, hit)
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (player.isSneaking)
|
||||
{
|
||||
doCharge = !doCharge
|
||||
println("Charge: " + doCharge)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import resonant.lib.render.RenderUtility
|
|||
import resonant.lib.transform.vector.Vector3
|
||||
|
||||
import scala.collection.convert.wrapAll._
|
||||
|
||||
/**
|
||||
* A kinetic energy to electrical energy converter.
|
||||
*
|
||||
|
@ -52,6 +53,7 @@ class TileMotor extends SpatialTile(Material.iron) with TElectric with TSpatialN
|
|||
nodes.add(dcNode)
|
||||
nodes.add(mechNode)
|
||||
|
||||
dcNode.resistance = 100
|
||||
dcNode.positiveTerminals.addAll(Seq(ForgeDirection.UP, ForgeDirection.SOUTH, ForgeDirection.EAST))
|
||||
dcNode.negativeTerminals.addAll(Seq(ForgeDirection.DOWN, ForgeDirection.NORTH, ForgeDirection.WEST))
|
||||
|
||||
|
@ -86,9 +88,10 @@ class TileMotor extends SpatialTile(Material.iron) with TElectric with TSpatialN
|
|||
else*/
|
||||
{
|
||||
//Produce mechanical energy
|
||||
val mechRatio = Math.pow(7, gearRatio) * 100 + 400
|
||||
val mechRatio = Math.pow(10, gearRatio)
|
||||
val power = dcNode.power
|
||||
mechNode.rotate(power * mechRatio, power / mechRatio)
|
||||
val negate = if (dcNode.potentialDifference > 0) 1 else -1
|
||||
mechNode.rotate(negate * power * mechRatio, negate * power / mechRatio)
|
||||
//TODO: Resist DC energy
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,6 +117,8 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
return wire.getThickness > getThickness
|
||||
}
|
||||
|
||||
def getThickness: Int = if (insulated) 1 else 0
|
||||
|
||||
/**
|
||||
* Packet Methods
|
||||
*/
|
||||
|
@ -220,28 +222,6 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
super.onChunkLoad()
|
||||
}
|
||||
|
||||
def dropIfCantStay: Boolean =
|
||||
{
|
||||
if (!canStay)
|
||||
{
|
||||
drop
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
def canStay: Boolean =
|
||||
{
|
||||
val pos: BlockCoord = new BlockCoord(tile).offset(side)
|
||||
return MultipartUtil.canPlaceWireOnSide(world, pos.x, pos.y, pos.z, ForgeDirection.getOrientation(side ^ 1), false)
|
||||
}
|
||||
|
||||
def drop
|
||||
{
|
||||
TileMultipart.dropItem(getItem, world, Vector3.fromTileEntityCenter(tile))
|
||||
tile.remPart(this)
|
||||
}
|
||||
|
||||
override def onAdded()
|
||||
{
|
||||
super.onAdded()
|
||||
|
@ -270,6 +250,28 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
sendPacket(3)
|
||||
}
|
||||
|
||||
def dropIfCantStay: Boolean =
|
||||
{
|
||||
if (!canStay)
|
||||
{
|
||||
drop
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
def canStay: Boolean =
|
||||
{
|
||||
val pos: BlockCoord = new BlockCoord(tile).offset(side)
|
||||
return MultipartUtil.canPlaceWireOnSide(world, pos.x, pos.y, pos.z, ForgeDirection.getOrientation(side ^ 1), false)
|
||||
}
|
||||
|
||||
def drop
|
||||
{
|
||||
TileMultipart.dropItem(getItem, world, Vector3.fromTileEntityCenter(tile))
|
||||
tile.remPart(this)
|
||||
}
|
||||
|
||||
def maskOpen(r: Int): Boolean =
|
||||
{
|
||||
return (connectionMask & 0x1000 << r) != 0
|
||||
|
@ -286,8 +288,6 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
|
||||
def getOcclusionBoxes: JIterable[Cuboid6] = Seq(PartFlatWire.occlusionBounds(getThickness)(side))
|
||||
|
||||
def getThickness: Int = if (insulated) 1 else 0
|
||||
|
||||
override def solid(arg0: Int) = false
|
||||
|
||||
/**
|
||||
|
@ -320,7 +320,7 @@ class PartFlatWire extends PartAbstract with TWire with TFacePart with TNormalOc
|
|||
TextureUtils.bindAtlas(0)
|
||||
CCRenderState.startDrawing(7)
|
||||
RenderFlatWire.render(this, pos)
|
||||
CCRenderState.draw
|
||||
CCRenderState.draw()
|
||||
CCRenderState.setColour(-1)
|
||||
GL11.glEnable(GL11.GL_LIGHTING)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue