Fixed conveyor/conduit crash / Improved conveyor movement
This commit is contained in:
@@ -110,8 +110,8 @@ public class Block extends BaseBlock implements Content{
|
|||||||
protected TextureRegion[] icon;
|
protected TextureRegion[] icon;
|
||||||
protected TextureRegion[] compactIcon;
|
protected TextureRegion[] compactIcon;
|
||||||
protected TextureRegion editorIcon;
|
protected TextureRegion editorIcon;
|
||||||
protected TextureRegion shadowRegion;
|
public TextureRegion shadowRegion;
|
||||||
protected TextureRegion region;
|
public TextureRegion region;
|
||||||
|
|
||||||
public Block(String name){
|
public Block(String name){
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ public class BuildBlock extends Block{
|
|||||||
Block previous = entity.previous;
|
Block previous = entity.previous;
|
||||||
|
|
||||||
if(recipe != null){
|
if(recipe != null){
|
||||||
recipe.result.drawShadow(tile);
|
Draw.rect(recipe.result.shadowRegion, tile.drawx(), tile.drawy());
|
||||||
}else if(previous != null){
|
}else if(previous != null){
|
||||||
previous.drawShadow(tile);
|
previous.drawShadow(tile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,23 +177,30 @@ public class Conveyor extends Block{
|
|||||||
entity.wakeUp();
|
entity.wakeUp();
|
||||||
|
|
||||||
float speed = this.speed * tilesize / 2.3f;
|
float speed = this.speed * tilesize / 2.3f;
|
||||||
|
float centerSpeed = 0.1f;
|
||||||
|
float centerDstScl = 3f;
|
||||||
float tx = Geometry.d4[tile.getRotation()].x, ty = Geometry.d4[tile.getRotation()].y;
|
float tx = Geometry.d4[tile.getRotation()].x, ty = Geometry.d4[tile.getRotation()].y;
|
||||||
|
|
||||||
float min;
|
float min;
|
||||||
|
float centerx = 0f, centery = 0f;
|
||||||
|
|
||||||
if(Math.abs(tx) > Math.abs(ty)){
|
if(Math.abs(tx) > Math.abs(ty)){
|
||||||
float rx = tile.worldx() - tx / 2f * tilesize;
|
float rx = tile.worldx() - tx / 2f * tilesize;
|
||||||
min = Mathf.clamp((unit.x - rx) * tx / tilesize);
|
min = Mathf.clamp((unit.x - rx) * tx / tilesize);
|
||||||
|
centery = Mathf.clamp((tile.worldy() - unit.y) / centerDstScl, -centerSpeed, centerSpeed);
|
||||||
|
if(Math.abs(tile.worldy() - unit.y) < 1f) centery = 0f;
|
||||||
}else{
|
}else{
|
||||||
float ry = tile.worldy() - ty / 2f * tilesize;
|
float ry = tile.worldy() - ty / 2f * tilesize;
|
||||||
min = Mathf.clamp((unit.y - ry) * ty / tilesize);
|
min = Mathf.clamp((unit.y - ry) * ty / tilesize);
|
||||||
|
centerx = Mathf.clamp((tile.worldx() - unit.x) / centerDstScl, -centerSpeed, centerSpeed);
|
||||||
|
if(Math.abs(tile.worldx() - unit.x) < 1f) centerx = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.minCarry = Math.min(entity.minCarry, min);
|
entity.minCarry = Math.min(entity.minCarry, min);
|
||||||
entity.carrying += unit.getMass();
|
entity.carrying += unit.getMass();
|
||||||
|
|
||||||
if(entity.convey.size * itemSpace < 0.9f){
|
if(entity.convey.size * itemSpace < 0.9f){
|
||||||
unit.getVelocity().add(tx * speed * Timers.delta(), ty * speed * Timers.delta());
|
unit.getVelocity().add((tx * speed + centerx) * Timers.delta(), (ty * speed + centery) * Timers.delta());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user