From f184b0700f2cab06ae07c862119fe9889f23d860 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 16 Jul 2018 21:44:15 -0400 Subject: [PATCH] Fixed conveyor/conduit crash / Improved conveyor movement --- core/src/io/anuke/mindustry/world/Block.java | 4 ++-- core/src/io/anuke/mindustry/world/blocks/BuildBlock.java | 2 +- .../mindustry/world/blocks/distribution/Conveyor.java | 9 ++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index a8961072a4..4b78de36a7 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -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; diff --git a/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java b/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java index ba9a5c4be4..9c085a3c06 100644 --- a/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/BuildBlock.java @@ -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); } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java index 8c20945cf7..72b6f5d398 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java @@ -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()); } }