Fixed gear ratio and gear connection around corners
This commit is contained in:
parent
c8e9e58761
commit
9d0fbdb272
9 changed files with 43 additions and 16 deletions
|
@ -402,6 +402,7 @@ public class TileLevitator extends TileAdvanced implements IPacketReceiver, IPac
|
|||
|
||||
public void updateBounds()
|
||||
{
|
||||
//TODO: Raytrace for block collision
|
||||
switch (getDirection())
|
||||
{
|
||||
case DOWN:
|
||||
|
|
|
@ -394,14 +394,23 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getRatio(ForgeDirection dir)
|
||||
public float getRatio(ForgeDirection dir, Object source)
|
||||
{
|
||||
if (dir == placementSide)
|
||||
if (source instanceof IMechanical)
|
||||
{
|
||||
return super.getRatio(dir);
|
||||
universalelectricity.api.vector.Vector3 deltaPos = ((IMechanical) source).getPosition().subtract(getPosition());
|
||||
|
||||
boolean caseX = placementSide.offsetX != 0 && deltaPos.y == 0 && deltaPos.z == 0;
|
||||
boolean caseY = placementSide.offsetY != 0 && deltaPos.x == 0 && deltaPos.z == 0;
|
||||
boolean caseZ = placementSide.offsetZ != 0 && deltaPos.x == 0 && deltaPos.y == 0;
|
||||
|
||||
if (caseX || caseY || caseZ)
|
||||
{
|
||||
return super.getRatio(dir, source);
|
||||
}
|
||||
}
|
||||
|
||||
return getMultiBlock().isConstructed() ? 1.5f : super.getRatio(dir);
|
||||
return getMultiBlock().isConstructed() ? 1.5f : super.getRatio(dir, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -431,7 +440,6 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
|
|||
* Check for flat connections (gear face on gear face) to make sure it's actually on
|
||||
* this gear block.
|
||||
*/
|
||||
System.out.println(getPosition() + ":" + from + " vs " + placementSide);
|
||||
if (from == placementSide.getOpposite())
|
||||
{
|
||||
if (source instanceof PartGear || source instanceof PartGearShaft)
|
||||
|
@ -449,14 +457,16 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
|
|||
|
||||
if (((PartGear) source).placementSide != placementSide)
|
||||
{
|
||||
/**
|
||||
* Case when we connect gears via edges internally. Large gear attempt
|
||||
* to connect to small gear.
|
||||
*/
|
||||
|
||||
TMultiPart part = tile().partMap(((PartGear) source).placementSide.ordinal());
|
||||
|
||||
if (part instanceof PartGear)
|
||||
{
|
||||
/**
|
||||
* Case when we connect gears via edges internally. Large gear
|
||||
* attempt
|
||||
* to connect to small gear.
|
||||
*/
|
||||
PartGear sourceGear = (PartGear) part;
|
||||
|
||||
if (sourceGear.isCenterMultiBlock() && !sourceGear.getMultiBlock().isPrimary())
|
||||
|
@ -465,6 +475,22 @@ public class PartGear extends PartMechanical implements IMechanical, IMultiBlock
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* Small gear attempting to connect to large gear.
|
||||
*/
|
||||
if (getMultiBlock().isConstructed())
|
||||
{
|
||||
TMultiPart checkPart = ((PartGear) source).tile().partMap(placementSide.ordinal());
|
||||
|
||||
if (checkPart instanceof PartGear)
|
||||
{
|
||||
ForgeDirection requiredDirection = ((PartGear) checkPart).getPosition().subtract(getPosition()).toForgeDirection();
|
||||
return ((PartGear) checkPart).isCenterMultiBlock() && ((PartGear) source).placementSide == requiredDirection;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public interface IMechanical extends IConnector<IMechanicalNetwork>
|
|||
|
||||
public void setTorque(long torque);
|
||||
|
||||
public float getRatio(ForgeDirection dir);
|
||||
public float getRatio(ForgeDirection dir, Object source);
|
||||
|
||||
public boolean inverseRotation(ForgeDirection dir, IMechanical with);
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
|||
|
||||
if (adjacentMech != null && adjacent != mechanical)
|
||||
{
|
||||
float ratio = adjacentMech.getRatio(dir.getOpposite()) / mechanical.getRatio(dir);
|
||||
float ratio = adjacentMech.getRatio(dir.getOpposite(), mechanical) / mechanical.getRatio(dir, adjacentMech);
|
||||
long torque = mechanical.getTorque();
|
||||
|
||||
boolean inverseRotation = mechanical.inverseRotation(dir, adjacentMech) && adjacentMech.inverseRotation(dir.getOpposite(), mechanical);
|
||||
|
|
|
@ -278,7 +278,7 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getRatio(ForgeDirection dir)
|
||||
public float getRatio(ForgeDirection dir, Object source)
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getRatio(ForgeDirection dir)
|
||||
public float getRatio(ForgeDirection dir, Object source)
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ public class TraitMechanical extends TileMultipart implements IMechanical
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getRatio(ForgeDirection dir)
|
||||
public float getRatio(ForgeDirection dir, Object source)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ public class TileWaterTurbine extends TileTurbine implements IMechanical
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getRatio(ForgeDirection dir)
|
||||
public float getRatio(ForgeDirection dir, Object source)
|
||||
{
|
||||
return getMultiBlock().isConstructed() ? 1.5f : 0.5f;
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ public class TileWindTurbine extends TileTurbine implements IMechanical
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getRatio(ForgeDirection dir)
|
||||
public float getRatio(ForgeDirection dir, Object source)
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue