Node Refactor

This commit is contained in:
Calclavia 2014-11-13 10:22:46 +08:00
parent 4272a0e850
commit 7f7bd3e696
21 changed files with 83 additions and 83 deletions

View file

@ -17,7 +17,7 @@ import resonant.lib.transform.vector.Vector3
import resonant.lib.utility.FluidUtility
import resonantinduction.archaic.fluid.grate.TileGrate._
import resonantinduction.core.Reference
import resonantinduction.core.prefab.node.{NodePressure, TileFluidProvider}
import resonantinduction.core.prefab.node.{NodeFluidPressure, TileFluidProvider}
object TileGrate
{
@ -51,7 +51,7 @@ object TileGrate
class TileGrate extends TileFluidProvider(Material.rock) with IRotatable
{
fluidNode = new NodePressure(this)
fluidNode = new NodeFluidPressure(this)
private var gratePath: GratePathfinder = _
private var fillOver: Boolean = true
isOpaqueCube = false
@ -95,7 +95,7 @@ class TileGrate extends TileFluidProvider(Material.rock) with IRotatable
{
if (ticks % 10 == 0)
{
val pressure = fluidNode.asInstanceOf[NodePressure].pressure(getDirection)
val pressure = fluidNode.asInstanceOf[NodeFluidPressure].pressure(getDirection)
val blockEffect = Math.abs(pressure * grateEffectMultiplier).toInt
fluidNode.getPrimaryTank.setCapacity(Math.max(blockEffect * FluidContainerRegistry.BUCKET_VOLUME * grateDrainSpeedMultiplier, FluidContainerRegistry.BUCKET_VOLUME).toInt)

View file

@ -2,15 +2,15 @@ package resonantinduction.archaic.fluid.gutter
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids.FluidContainerRegistry
import resonantinduction.core.prefab.node.{NodePressure, TileFluidProvider}
import resonantinduction.core.prefab.node.{NodeFluidPressure, TileFluidProvider}
/**
* A node for fluid that follows pressure and gravity.
* @author Calclavia
*/
class NodePressureGravity(parent: TileFluidProvider, volume: Int = FluidContainerRegistry.BUCKET_VOLUME) extends NodePressure(parent, volume)
class NodeFluidGravity(parent: TileFluidProvider, volume: Int = FluidContainerRegistry.BUCKET_VOLUME) extends NodeFluidPressure(parent, volume)
{
override protected def doDistribute(dir: ForgeDirection, nodeA: NodePressure, nodeB: NodePressure, flowRate: Int)
override protected def doDistribute(dir: ForgeDirection, nodeA: NodeFluidPressure, nodeB: NodeFluidPressure, flowRate: Int)
{
val tankA = nodeA.getPrimaryTank
val tankB = nodeB.getPrimaryTank
@ -23,7 +23,7 @@ class NodePressureGravity(parent: TileFluidProvider, volume: Int = FluidContaine
if (dir == ForgeDirection.DOWN)
quantity = Math.max(if (pressureA > pressureB) (pressureA - pressureB) * flowRate else amountA, amountA)
else if (nodeB.isInstanceOf[NodePressureGravity])
else if (nodeB.isInstanceOf[NodeFluidGravity])
quantity = Math.max(if (pressureA > pressureB) (pressureA - pressureB) * flowRate else Math.min((amountA - amountB) / 2, flowRate), Math.min((amountA - amountB) / 2, flowRate))
else
quantity = if (pressureA > pressureB) (pressureA - pressureB) * flowRate else 0

View file

@ -23,7 +23,7 @@ import resonant.lib.utility.FluidUtility
import resonant.lib.utility.inventory.InventoryUtility
import resonant.lib.wrapper.BitmaskWrapper._
import resonantinduction.core.Reference
import resonantinduction.core.prefab.node.{NodePressure, TileFluidProvider}
import resonantinduction.core.prefab.node.{NodeFluidPressure, TileFluidProvider}
object TileGutter
{
@ -38,7 +38,7 @@ object TileGutter
*/
class TileGutter extends TileFluidProvider(Material.rock)
{
fluidNode = new NodePressureGravity(this)
fluidNode = new NodeFluidGravity(this)
{
override def canFill(from: ForgeDirection, fluid: Fluid): Boolean =
{
@ -102,13 +102,13 @@ class TileGutter extends TileFluidProvider(Material.rock)
for (i <- 2 to 6)
{
val dir: ForgeDirection = ForgeDirection.getOrientation(i)
val pressure: Int = fluidNode.asInstanceOf[NodePressure].pressure(dir)
val pressure: Int = fluidNode.asInstanceOf[NodeFluidPressure].pressure(dir)
val pos: Vector3 = toVector3.add(dir)
val checkTile: TileEntity = pos.getTileEntity(world)
if (checkTile.isInstanceOf[TileGutter])
{
val deltaPressure: Int = pressure - checkTile.asInstanceOf[TileGutter].fluidNode.asInstanceOf[NodePressure].pressure(dir.getOpposite)
val deltaPressure: Int = pressure - checkTile.asInstanceOf[TileGutter].fluidNode.asInstanceOf[NodeFluidPressure].pressure(dir.getOpposite)
entity.motionX += 0.01 * dir.offsetX * deltaPressure
entity.motionY += 0.01 * dir.offsetY * deltaPressure
entity.motionZ += 0.01 * dir.offsetZ * deltaPressure

View file

@ -23,7 +23,7 @@ import resonant.lib.utility.FluidUtility
import resonant.lib.utility.render.RenderBlockUtility
import resonant.lib.wrapper.BitmaskWrapper._
import resonantinduction.archaic.ArchaicContent
import resonantinduction.archaic.fluid.gutter.NodePressureGravity
import resonantinduction.archaic.fluid.gutter.NodeFluidGravity
import resonantinduction.core.Reference
import resonantinduction.core.prefab.node.TileFluidProvider
@ -39,7 +39,7 @@ class TileTank extends TileFluidProvider(Material.iron) with ISneakPickup with R
normalRender = false
itemBlock = classOf[ItemBlockTank]
fluidNode = new NodePressureGravity(this, 16 * FluidContainerRegistry.BUCKET_VOLUME)
fluidNode = new NodeFluidGravity(this, 16 * FluidContainerRegistry.BUCKET_VOLUME)
{
override def connect[B <: IFluidHandler](obj: B, dir: ForgeDirection)
{
@ -50,7 +50,7 @@ class TileTank extends TileFluidProvider(Material.iron) with ISneakPickup with R
}
}
fluidNode.asInstanceOf[NodePressureGravity].maxFlowRate = FluidContainerRegistry.BUCKET_VOLUME
fluidNode.asInstanceOf[NodeFluidGravity].maxFlowRate = FluidContainerRegistry.BUCKET_VOLUME
fluidNode.onFluidChanged = () => if(!world.isRemote) sendPacket(0)
override def shouldSideBeRendered(access: IBlockAccess, x: Int, y: Int, z: Int, side: Int): Boolean = new Vector3(x, y, z).getBlock(access) != block
@ -59,7 +59,7 @@ class TileTank extends TileFluidProvider(Material.iron) with ISneakPickup with R
{
if (!world.isRemote)
{
println(fluidNode.asInstanceOf[NodePressureGravity].pressure)
println(fluidNode.asInstanceOf[NodeFluidGravity].pressure)
return FluidUtility.playerActivatedFluidItem(world, xi, yi, zi, player, side)
}

View file

@ -5,7 +5,7 @@ import net.minecraftforge.fluids.{FluidContainerRegistry, IFluidHandler}
import resonant.api.grid.{INodeProvider, IUpdate}
import resonant.lib.grid.UpdateTicker
import resonant.lib.prefab.fluid.NodeFluid
import resonantinduction.archaic.fluid.gutter.NodePressureGravity
import resonantinduction.archaic.fluid.gutter.NodeFluidGravity
import scala.collection.convert.wrapAll._
@ -17,7 +17,7 @@ import scala.collection.convert.wrapAll._
*
* @author Calclavia
*/
class NodePressure(parent: INodeProvider, volume: Int = FluidContainerRegistry.BUCKET_VOLUME) extends NodeFluid(parent, volume) with IUpdate
class NodeFluidPressure(parent: INodeProvider, volume: Int = FluidContainerRegistry.BUCKET_VOLUME) extends NodeFluid(parent, volume) with IUpdate
{
var maxFlowRate = 1000
var maxPressure = 100
@ -46,11 +46,11 @@ class NodePressure(parent: INodeProvider, volume: Int = FluidContainerRegistry.B
{
case (handler: IFluidHandler, dir: ForgeDirection) =>
{
if (handler.isInstanceOf[NodePressure])
if (handler.isInstanceOf[NodeFluidPressure])
{
//"A" is this node. "B" is the other node
//It's another pressure node
val otherNode = handler.asInstanceOf[NodePressure]
val otherNode = handler.asInstanceOf[NodeFluidPressure]
val pressureA = pressure(dir)
val pressureB = otherNode.pressure(dir.getOpposite)
@ -112,7 +112,7 @@ class NodePressure(parent: INodeProvider, volume: Int = FluidContainerRegistry.B
}
}
protected def doDistribute(dir: ForgeDirection, nodeA: NodePressure, nodeB: NodePressure, flowRate: Int)
protected def doDistribute(dir: ForgeDirection, nodeA: NodeFluidPressure, nodeB: NodeFluidPressure, flowRate: Int)
{
val tankA = nodeA.getPrimaryTank
val tankB = nodeB.getPrimaryTank
@ -145,9 +145,9 @@ class NodePressure(parent: INodeProvider, volume: Int = FluidContainerRegistry.B
{
case (handler: IFluidHandler, dir: ForgeDirection) =>
{
if (handler.isInstanceOf[NodePressure])
if (handler.isInstanceOf[NodeFluidPressure])
{
val node = handler.asInstanceOf[NodePressure]
val node = handler.asInstanceOf[NodeFluidPressure]
val pressure = node.pressure(dir.getOpposite)
minPressure = Math.min(pressure, minPressure)
maxPressure = Math.max(pressure, maxPressure)

View file

@ -9,7 +9,7 @@ import resonant.content.prefab.java.TileAdvanced
import resonant.lib.content.prefab.TElectric
import resonant.lib.grid.node.TSpatialNodeProvider
import resonant.lib.transform.vector.Vector3
import resonantinduction.mechanical.mech.grid.MechanicalNode
import resonantinduction.mechanical.mech.grid.NodeMechanical
/**
* A kinetic energy to electrical energy converter.
@ -18,7 +18,7 @@ import resonantinduction.mechanical.mech.grid.MechanicalNode
*/
class TileMotor extends TileAdvanced(Material.iron) with TElectric with TSpatialNodeProvider with IRotatable
{
var mechNode = new MechanicalNode(this)
var mechNode = new NodeMechanical(this)
private var gearRatio = 0

View file

@ -15,7 +15,7 @@ import resonantinduction.mechanical.machine.TileDetector
import resonantinduction.mechanical.machine.edit.{TileBreaker, TilePlacer}
import resonantinduction.mechanical.mech.gear.{ItemGear, PartGear}
import resonantinduction.mechanical.mech.gearshaft.{ItemGearShaft, PartGearShaft}
import resonantinduction.mechanical.mech.grid.MechanicalNode
import resonantinduction.mechanical.mech.grid.NodeMechanical
import resonantinduction.mechanical.mech.process.crusher.TileMechanicalPiston
import resonantinduction.mechanical.mech.process.grinder.TileGrindingWheel
import resonantinduction.mechanical.mech.process.mixer.TileMixer
@ -71,7 +71,7 @@ object MechanicalContent extends ContentHolder
SchematicRegistry.register("resonantinduction.mechanical.windTurbine",new SchematicPlate("schematic.windTurbine.name", MechanicalContent.blockWindTurbine))
SchematicRegistry.register("resonantinduction.mechanical.electricalTurbine",new SchematicPlate("schematic.electricTurbine.name", MechanicalContent.blockElectricTurbine))
NodeRegistry.register(classOf[TMechanicalNode], classOf[MechanicalNode])
NodeRegistry.register(classOf[TMechanicalNode], classOf[NodeMechanical])
RICreativeTab.itemStack(new ItemStack(MechanicalContent.blockGrinderWheel))

View file

@ -3,7 +3,7 @@ package resonantinduction.mechanical.fluid.pipe
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids.IFluidHandler
import resonant.api.grid.INodeProvider
import resonantinduction.core.prefab.node.{NodePressure, TMultipartNode}
import resonantinduction.core.prefab.node.{NodeFluidPressure, TMultipartNode}
import resonantinduction.core.prefab.part.connector.TColorable
/**
@ -11,7 +11,7 @@ import resonantinduction.core.prefab.part.connector.TColorable
*
* @author Calclavia, Darkguardsman
*/
class NodePipe(parent: PartPipe) extends NodePressure(parent) with TMultipartNode[IFluidHandler]
class NodePipe(parent: PartPipe) extends NodeFluidPressure(parent) with TMultipartNode[IFluidHandler]
{
def pipe: PartPipe = getParent.asInstanceOf[PartPipe]
@ -25,9 +25,9 @@ class NodePipe(parent: PartPipe) extends NodePressure(parent) with TMultipartNod
{
if (tile.isInstanceOf[INodeProvider])
{
val check = tile.asInstanceOf[INodeProvider].getNode(classOf[NodePressure], dir.getOpposite)
val check = tile.asInstanceOf[INodeProvider].getNode(classOf[NodeFluidPressure], dir.getOpposite)
if (check.isInstanceOf[NodePressure] && canConnect(check, dir) && check.asInstanceOf[NodePressure].canConnect(this, dir.getOpposite))
if (check.isInstanceOf[NodeFluidPressure] && canConnect(check, dir) && check.asInstanceOf[NodeFluidPressure].canConnect(this, dir.getOpposite))
{
connect(check, dir)
}

View file

@ -3,13 +3,13 @@ package resonantinduction.mechanical.fluid.transport
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids.IFluidHandler
import resonant.api.grid.INodeProvider
import resonantinduction.core.prefab.node.NodePressure
import resonantinduction.core.prefab.node.NodeFluidPressure
/**
* A node for the pump
* @author Calclavia
*/
class PumpNode(parent: INodeProvider) extends NodePressure(parent)
class PumpNode(parent: INodeProvider) extends NodeFluidPressure(parent)
{
def pump: TilePump = getParent.asInstanceOf[TilePump]

View file

@ -17,7 +17,7 @@ import resonant.lib.debug.UpdatePanel;
import resonant.lib.debug.UpdatedLabel;
import resonant.api.grid.INode;
import resonant.api.grid.INodeProvider;
import resonantinduction.mechanical.mech.grid.MechanicalNode;
import resonantinduction.mechanical.mech.grid.NodeMechanical;
/** Java GUI used to help debug gear information
*
@ -31,7 +31,7 @@ public class DebugFrameMechanical extends FrameNodeDebug
public DebugFrameMechanical(INodeProvider node)
{
super(node, MechanicalNode.class);
super(node, NodeMechanical.class);
}
@Override
@ -104,7 +104,7 @@ public class DebugFrameMechanical extends FrameNodeDebug
if (getNode() != null && getNode().connections() != null)
{
ForgeDirection dir = (ForgeDirection) getNode().directionMap().values().toArray()[row];
MechanicalNode node = (MechanicalNode) getNode().directionMap().keySet().toArray()[row];
NodeMechanical node = (NodeMechanical) getNode().directionMap().keySet().toArray()[row];
switch(col)
{
case 0: return dir;
@ -160,12 +160,12 @@ public class DebugFrameMechanical extends FrameNodeDebug
}
@Override
public MechanicalNode getNode()
public NodeMechanical getNode()
{
INode node = super.getNode();
if (node instanceof MechanicalNode)
if (node instanceof NodeMechanical)
{
return (MechanicalNode) node;
return (NodeMechanical) node;
}
return null;
}

View file

@ -9,7 +9,7 @@ import net.minecraft.util.MovingObjectPosition
import net.minecraftforge.common.util.ForgeDirection
import resonant.lib.transform.vector.VectorWorld
import resonantinduction.core.prefab.part.connector.{PartAbstract, TPartNodeProvider}
import resonantinduction.mechanical.mech.grid.MechanicalNode
import resonantinduction.mechanical.mech.grid.NodeMechanical
/** We assume all the force acting on the gear is 90 degrees.
*
@ -17,13 +17,13 @@ import resonantinduction.mechanical.mech.grid.MechanicalNode
abstract class PartMechanical extends PartAbstract with JNormalOcclusion with TFacePart with TPartNodeProvider with TCuboidPart
{
/** Node that handles resonantinduction.mechanical action of the machine */
private var _mechanicalNode: MechanicalNode = null
private var _mechanicalNode: NodeMechanical = null
protected var markVelocityUpdate = false
def mechanicalNode = _mechanicalNode
def mechanicalNode_=(mech: MechanicalNode)
def mechanicalNode_=(mech: NodeMechanical)
{
_mechanicalNode = mech
mechanicalNode.onVelocityChanged = () => markVelocityUpdate = true

View file

@ -14,7 +14,7 @@ import resonant.lib.network.ByteBufWrapper._
import resonant.lib.network.discriminator.PacketType
import resonant.lib.network.handle.{TPacketReceiver, TPacketSender}
import resonant.lib.transform.vector.Vector3
import resonantinduction.mechanical.mech.grid.MechanicalNode
import resonantinduction.mechanical.mech.grid.NodeMechanical
/** Prefab for resonantinduction.mechanical tiles
*
@ -22,11 +22,11 @@ import resonantinduction.mechanical.mech.grid.MechanicalNode
abstract class TileMechanical(material: Material) extends SpatialTile(material: Material) with TRotatable with TSpatialNodeProvider with TPacketSender with TPacketReceiver
{
/** Node that handles most mechanical actions */
private var _mechanicalNode: MechanicalNode = null
private var _mechanicalNode: NodeMechanical = null
def mechanicalNode = _mechanicalNode
def mechanicalNode_=(newNode: MechanicalNode)
def mechanicalNode_=(newNode: NodeMechanical)
{
_mechanicalNode = newNode
mechanicalNode.onVelocityChanged = () => markPacket = true
@ -38,7 +38,7 @@ abstract class TileMechanical(material: Material) extends SpatialTile(material:
/** External debug GUI */
var frame: DebugFrameMechanical = null
mechanicalNode = new MechanicalNode(this)
mechanicalNode = new NodeMechanical(this)
override def update()
{

View file

@ -9,14 +9,14 @@ import resonant.lib.transform.vector.{IVectorWorld, Vector3, VectorWorld}
import resonant.lib.wrapper.ForgeDirectionWrapper._
import resonantinduction.core.interfaces.TMechanicalNode
import resonantinduction.mechanical.mech.gearshaft.{GearShaftNode, PartGearShaft}
import resonantinduction.mechanical.mech.grid.MechanicalNode
import resonantinduction.mechanical.mech.grid.NodeMechanical
/**
* Node for the gear
*
* @author Calclavia, Edited by: Darkguardsman
*/
class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
class GearNode(parent: PartGear) extends NodeMechanical(parent: PartGear)
{
angleDisplacement = Math.PI / 12
@ -52,7 +52,7 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
val tileBehind: TileEntity = new Vector3(gear.tile).add(gear.placementSide).getTileEntity(world)
if (tileBehind.isInstanceOf[INodeProvider])
{
val instance: MechanicalNode = (tileBehind.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], gear.placementSide.getOpposite)
val instance: NodeMechanical = (tileBehind.asInstanceOf[INodeProvider]).getNode(classOf[NodeMechanical], gear.placementSide.getOpposite)
if (instance != null && instance != this && !(instance.getParent.isInstanceOf[PartGearShaft]) && instance.canConnect(this, gear.placementSide.getOpposite))
{
connect(instance, gear.placementSide)
@ -68,7 +68,7 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
}
if (tile.isInstanceOf[INodeProvider])
{
val instance: MechanicalNode = (tile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], if (checkDir == gear.placementSide.getOpposite) ForgeDirection.UNKNOWN else checkDir).asInstanceOf[MechanicalNode]
val instance: NodeMechanical = (tile.asInstanceOf[INodeProvider]).getNode(classOf[NodeMechanical], if (checkDir == gear.placementSide.getOpposite) ForgeDirection.UNKNOWN else checkDir).asInstanceOf[NodeMechanical]
if (!directionMap.containsValue(checkDir) && instance != this && checkDir != gear.placementSide && instance != null && instance.canConnect(this, checkDir.getOpposite))
{
connect(instance, checkDir)
@ -86,7 +86,7 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
val checkTile: TileEntity = new Vector3(gear.tile).add(checkDir).getTileEntity(world)
if (!directionMap.containsValue(checkDir) && checkTile.isInstanceOf[INodeProvider])
{
val instance: MechanicalNode = (checkTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], gear.placementSide)
val instance: NodeMechanical = (checkTile.asInstanceOf[INodeProvider]).getNode(classOf[NodeMechanical], gear.placementSide)
if (instance != null && instance != this && instance.canConnect(this, checkDir.getOpposite) && !(instance.getParent.isInstanceOf[PartGearShaft]))
{
connect(instance, checkDir)
@ -108,9 +108,9 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
{
return false
}
if (other.isInstanceOf[MechanicalNode])
if (other.isInstanceOf[NodeMechanical])
{
val parent: INodeProvider = other.asInstanceOf[MechanicalNode].getParent
val parent: INodeProvider = other.asInstanceOf[NodeMechanical].getParent
if (from == gear.placementSide.getOpposite)
{
if (parent.isInstanceOf[PartGear] || parent.isInstanceOf[PartGearShaft])
@ -157,7 +157,7 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
val sourceTile: TileEntity = toVectorWorld.add(from.getOpposite).getTileEntity(world)
if (sourceTile.isInstanceOf[INodeProvider])
{
val sourceInstance: MechanicalNode = (sourceTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], from)
val sourceInstance: NodeMechanical = (sourceTile.asInstanceOf[INodeProvider]).getNode(classOf[NodeMechanical], from)
return sourceInstance == other
}
}
@ -166,13 +166,13 @@ class GearNode(parent: PartGear) extends MechanicalNode(parent: PartGear)
val sourceTile: TileEntity = toVectorWorld.add(from).getTileEntity(world)
if (sourceTile.isInstanceOf[INodeProvider])
{
val sourceInstance: MechanicalNode = (sourceTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], from.getOpposite)
val sourceInstance: NodeMechanical = (sourceTile.asInstanceOf[INodeProvider]).getNode(classOf[NodeMechanical], from.getOpposite)
return sourceInstance == other
}
}
else
{
val destinationTile: TileEntity = other.asInstanceOf[MechanicalNode].toVectorWorld.add(from.getOpposite).getTileEntity(world)
val destinationTile: TileEntity = other.asInstanceOf[NodeMechanical].toVectorWorld.add(from.getOpposite).getTileEntity(world)
if (destinationTile.isInstanceOf[INodeProvider] && destinationTile.isInstanceOf[TileMultipart])
{
val destinationPart: TMultiPart = destinationTile.asInstanceOf[TileMultipart].partMap(gear.placementSide.ordinal)

View file

@ -6,9 +6,9 @@ import resonant.lib.transform.vector.Vector3
import resonant.lib.wrapper.ForgeDirectionWrapper._
import resonantinduction.core.interfaces.TMechanicalNode
import resonantinduction.mechanical.mech.gear.{GearNode, PartGear}
import resonantinduction.mechanical.mech.grid.MechanicalNode
import resonantinduction.mechanical.mech.grid.NodeMechanical
class GearShaftNode(parent: PartGearShaft) extends MechanicalNode(parent)
class GearShaftNode(parent: PartGearShaft) extends NodeMechanical(parent)
{
override def getTorqueLoad: Double =
{
@ -38,7 +38,7 @@ class GearShaftNode(parent: PartGearShaft) extends MechanicalNode(parent)
var found = false
///Check within this block for another gear plate that will move this shaft
val otherNode = shaft.tile.asInstanceOf[INodeProvider].getNode(classOf[MechanicalNode], toDir)
val otherNode = shaft.tile.asInstanceOf[INodeProvider].getNode(classOf[NodeMechanical], toDir)
if (otherNode != null && otherNode != this && canConnect(otherNode, toDir) && otherNode.canConnect(this, toDir.getOpposite))
{
@ -53,7 +53,7 @@ class GearShaftNode(parent: PartGearShaft) extends MechanicalNode(parent)
if (checkTile.isInstanceOf[INodeProvider])
{
val instance = (checkTile.asInstanceOf[INodeProvider]).getNode(classOf[MechanicalNode], toDir.getOpposite)
val instance = (checkTile.asInstanceOf[INodeProvider]).getNode(classOf[NodeMechanical], toDir.getOpposite)
if (instance != null && instance != this && instance.getParent.isInstanceOf[PartGearShaft] && instance.canConnect(this, toDir.getOpposite))
{
@ -66,11 +66,11 @@ class GearShaftNode(parent: PartGearShaft) extends MechanicalNode(parent)
override def canConnect[B](other: B, from: ForgeDirection): Boolean =
{
if (other.isInstanceOf[MechanicalNode])
if (other.isInstanceOf[NodeMechanical])
{
if ((other.asInstanceOf[MechanicalNode]).getParent.isInstanceOf[PartGear])
if ((other.asInstanceOf[NodeMechanical]).getParent.isInstanceOf[PartGear])
{
val gear: PartGear = (other.asInstanceOf[MechanicalNode]).getParent.asInstanceOf[PartGear]
val gear: PartGear = (other.asInstanceOf[NodeMechanical]).getParent.asInstanceOf[PartGear]
if (!(Math.abs(gear.placementSide.offsetX) == Math.abs(shaft.placementSide.offsetX) && Math.abs(gear.placementSide.offsetY) == Math.abs(shaft.placementSide.offsetY) && Math.abs(gear.placementSide.offsetZ) == Math.abs(shaft.placementSide.offsetZ)))
{
return false

View file

@ -10,14 +10,14 @@ import scala.collection.mutable
* A grid that manages the mechanical objects
* @author Calclavia
*/
class MechanicalGrid extends GridNode[MechanicalNode](classOf[MechanicalNode]) with IUpdate
class MechanicalGrid extends GridNode[NodeMechanical](classOf[NodeMechanical]) with IUpdate
{
/**
* A map marking out the relative spin directions of each node.
* Updated upon recache
*/
val spinMap = mutable.WeakHashMap.empty[MechanicalNode, Boolean]
val spinMap = mutable.WeakHashMap.empty[NodeMechanical, Boolean]
/**
* The power of the mechanical grid
@ -30,13 +30,13 @@ class MechanicalGrid extends GridNode[MechanicalNode](classOf[MechanicalNode]) w
/**
* Rebuild the node list starting from the first node and recursively iterating through its connections.
*/
override def reconstruct(first: MechanicalNode)
override def reconstruct(first: NodeMechanical)
{
super.reconstruct(first)
UpdateTicker.addUpdater(this)
}
override protected def populateNode(node: MechanicalNode, prev: MechanicalNode)
override protected def populateNode(node: NodeMechanical, prev: NodeMechanical)
{
super.populateNode(node, prev)

View file

@ -13,7 +13,7 @@ import resonantinduction.core.prefab.node.TMultipartNode
*
* @author Calclavia, Darkguardsman
*/
class MechanicalNode(parent: INodeProvider) extends NodeGrid[MechanicalNode](parent) with TMultipartNode[MechanicalNode] with TMechanicalNode with IVectorWorld
class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](parent) with TMultipartNode[NodeMechanical] with TMechanicalNode with IVectorWorld
{
var torque = 0D
var angularVelocity = 0D
@ -86,9 +86,9 @@ class MechanicalNode(parent: INodeProvider) extends NodeGrid[MechanicalNode](par
//TODO: Create new grids automatically?
def power: Double = if (getMechanicalGrid != null) getMechanicalGrid.power else 0
def getMechanicalGrid: MechanicalGrid = super.getGrid.asInstanceOf[MechanicalGrid]
def getMechanicalGrid: MechanicalGrid = super.grid.asInstanceOf[MechanicalGrid]
override def newGrid: GridNode[MechanicalNode] = new MechanicalGrid
override def newGrid: GridNode[NodeMechanical] = new MechanicalGrid
override def isValidConnection(other: AnyRef): Boolean = other.isInstanceOf[MechanicalNode]
override def isValidConnection(other: AnyRef): Boolean = other.isInstanceOf[NodeMechanical]
}

View file

@ -1,12 +1,12 @@
package resonantinduction.mechanical.mech.process.crusher
import net.minecraftforge.common.util.ForgeDirection
import resonantinduction.mechanical.mech.grid.MechanicalNode
import resonantinduction.mechanical.mech.grid.NodeMechanical
/**
* Created by robert on 8/28/2014.
*/
class NodeMechanicalPiston(parent: TileMechanicalPiston) extends MechanicalNode(parent)
class NodeMechanicalPiston(parent: TileMechanicalPiston) extends NodeMechanical(parent)
{
override def canConnect(dir: ForgeDirection): Boolean =
{

View file

@ -1,12 +1,12 @@
package resonantinduction.mechanical.mech.process.grinder
import net.minecraftforge.common.util.ForgeDirection
import resonantinduction.mechanical.mech.grid.MechanicalNode
import resonantinduction.mechanical.mech.grid.NodeMechanical
/** Node just for the grinder
*
* @author Darkguardsman */
class GrinderNode(parent: TileGrindingWheel) extends MechanicalNode(parent: TileGrindingWheel)
class GrinderNode(parent: TileGrindingWheel) extends NodeMechanical(parent: TileGrindingWheel)
{
def grider: TileGrindingWheel =
{

View file

@ -2,13 +2,13 @@ package resonantinduction.mechanical.mech.process.mixer
import net.minecraftforge.common.util.ForgeDirection
import resonant.api.grid.INodeProvider
import resonantinduction.mechanical.mech.grid.MechanicalNode
import resonantinduction.mechanical.mech.grid.NodeMechanical
/**
* Node designed just for the Mixer to use
* @param parent - instance of TileMixer that will host this node, should never be null
*/
class MixerNode(parent: INodeProvider) extends MechanicalNode(parent)
class MixerNode(parent: INodeProvider) extends NodeMechanical(parent)
{
override def canConnect(direction: ForgeDirection): Boolean =
{

View file

@ -17,7 +17,7 @@ import resonant.lib.wrapper.WrapList._
import resonantinduction.core.Settings
import resonant.api.grid.INodeProvider
import resonant.lib.transform.vector.Vector3
import resonantinduction.mechanical.mech.grid.MechanicalNode
import resonantinduction.mechanical.mech.grid.NodeMechanical
/**
* The vertical water turbine collects flowing water flowing on X axis.
@ -37,12 +37,12 @@ class TileWaterTurbine extends TileTurbine
{
override def canConnect[B](other: B, from: ForgeDirection): Boolean =
{
if (other.isInstanceOf[MechanicalNode] && !(other.isInstanceOf[TileTurbine]))
if (other.isInstanceOf[NodeMechanical] && !(other.isInstanceOf[TileTurbine]))
{
val sourceTile: TileEntity = position.add(from).getTileEntity(getWorld)
val sourceTile: TileEntity = toVectorWorld.add(from).getTileEntity
if (sourceTile.isInstanceOf[INodeProvider])
{
val sourceInstance: MechanicalNode = sourceTile.asInstanceOf[INodeProvider].getNode(classOf[MechanicalNode], from.getOpposite).asInstanceOf[MechanicalNode]
val sourceInstance: NodeMechanical = sourceTile.asInstanceOf[INodeProvider].getNode(classOf[NodeMechanical], from.getOpposite).asInstanceOf[NodeMechanical]
return sourceInstance == other && (from == getDirection.getOpposite || from == getDirection)
}
}

View file

@ -1,7 +1,7 @@
package resonantinduction.mechanical.mech.turbine
import net.minecraftforge.common.util.ForgeDirection
import resonantinduction.mechanical.mech.grid.MechanicalNode
import resonantinduction.mechanical.mech.grid.NodeMechanical
/**
* Turbine's Mechanical node
@ -9,7 +9,7 @@ import resonantinduction.mechanical.mech.grid.MechanicalNode
*
* @author Calclavia, Darkguardsman
*/
class TurbineNode(tileTurbineBase: TileTurbine) extends MechanicalNode(tileTurbineBase)
class TurbineNode(tileTurbineBase: TileTurbine) extends NodeMechanical(tileTurbineBase)
{
def turbine: TileTurbine =
@ -19,7 +19,7 @@ class TurbineNode(tileTurbineBase: TileTurbine) extends MechanicalNode(tileTurbi
override def canConnect[B](other: B, from: ForgeDirection): Boolean =
{
return turbine.getMultiBlock.isPrimary && other.isInstanceOf[MechanicalNode] && !(other.isInstanceOf[TurbineNode]) && from == turbine.getDirection
return turbine.getMultiBlock.isPrimary && other.isInstanceOf[NodeMechanical] && !(other.isInstanceOf[TurbineNode]) && from == turbine.getDirection
}
/**