Fixed conveyor/conduit crash / Improved conveyor movement

This commit is contained in:
Anuken 2018-07-16 21:44:15 -04:00
parent 07f0be8d8d
commit f184b0700f
3 changed files with 11 additions and 4 deletions

View File

@ -110,8 +110,8 @@ public class Block extends BaseBlock implements Content{
protected TextureRegion[] icon;
protected TextureRegion[] compactIcon;
protected TextureRegion editorIcon;
protected TextureRegion shadowRegion;
protected TextureRegion region;
public TextureRegion shadowRegion;
public TextureRegion region;
public Block(String name){
this.name = name;

View File

@ -158,7 +158,7 @@ public class BuildBlock extends Block{
Block previous = entity.previous;
if(recipe != null){
recipe.result.drawShadow(tile);
Draw.rect(recipe.result.shadowRegion, tile.drawx(), tile.drawy());
}else if(previous != null){
previous.drawShadow(tile);
}

View File

@ -177,23 +177,30 @@ public class Conveyor extends Block{
entity.wakeUp();
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 min;
float centerx = 0f, centery = 0f;
if(Math.abs(tx) > Math.abs(ty)){
float rx = tile.worldx() - tx / 2f * 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{
float ry = tile.worldy() - ty / 2f * 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.carrying += unit.getMass();
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());
}
}