1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-13 07:15:28 +03:00

Fixed a few bugs with new placement system

This commit is contained in:
Anuken 2018-05-18 09:22:40 -07:00
parent 19e62786c9
commit afed54b217
12 changed files with 17 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -42,7 +42,6 @@ public class Player extends Unit implements BlockPlacer{
static final float dashSpeed = 1.8f;
public static final float placeDistance = 80f;
static final int timerDash = 0;
static final int timerRegen = 3;
static final Translator[] tmptr = {new Translator(), new Translator(), new Translator(), new Translator()};
@ -229,7 +228,7 @@ public class Player extends Unit implements BlockPlacer{
@Override
public void drawOver(){
if(!isShooting() && currentPlace != null) {
Draw.color("accent");
Draw.color(distanceTo(currentPlace) > placeDistance ? "placeInvalid" : "accent");
float focusLen = 3.8f + Mathf.absin(Timers.time(), 1.1f, 0.6f);
float px = x + Angles.trnsx(rotation, focusLen);
float py = y + Angles.trnsy(rotation, focusLen);
@ -320,10 +319,6 @@ public class Player extends Unit implements BlockPlacer{
return placeQueue;
}
private boolean invalidPlaceBlock(Tile check){
return (!(check.block() instanceof BuildBlock) || distanceTo(check) > placeDistance);
}
protected void updateMech(){
Tile tile = world.tileWorld(x, y);
@ -334,21 +329,24 @@ public class Player extends Unit implements BlockPlacer{
}
if(!isShooting()) {
//update placing queue
if(currentPlace != null) {
Tile check = currentPlace;
if (invalidPlaceBlock(currentPlace)) {
if (!(check.block() instanceof BuildBlock)) {
currentPlace = null;
}else {
}else if(distanceTo(check) <= placeDistance){
BuildEntity entity = check.entity();
entity.progress += 1f / entity.result.health;
rotation = Mathf.slerpDelta(rotation, angleTo(entity), 0.4f);
}
}else if(placeQueue.size > 0){
PlaceRequest check = placeQueue.removeLast();
if(Placement.validPlace(team, check.x, check.y, check.recipe.result, check.rotation)){
PlaceRequest check = placeQueue.last();
if(distanceTo(world.tile(check.x, check.y)) <= placeDistance &&
Placement.validPlace(team, check.x, check.y, check.recipe.result, check.rotation)){
placeQueue.removeLast();
Placement.placeBlock(team, check.x, check.y, check.recipe, check.rotation, true, true);
currentPlace = world.tile(check.x, check.y);
}

View File

@ -67,6 +67,7 @@ public class Placement {
tile.setBlock(sub, rotation);
tile.<BuildEntity>entity().result = result;
tile.<BuildEntity>entity().stacks = recipe.requirements;
tile.setTeam(team);
if(result.isMultiblock()){
@ -88,9 +89,13 @@ public class Placement {
if(effects) Effects.effect(Fx.none, worldx * tilesize, worldy * tilesize);
}
}
}else if(effects) Effects.effect(Fx.none, x * tilesize, y * tilesize);
}else if(effects){
Effects.effect(Fx.none, x * tilesize, y * tilesize);
}
if(effects && sound) threads.run(() -> Effects.sound("place", x * tilesize, y * tilesize));
if(effects && sound){
threads.run(() -> Effects.sound("place", x * tilesize, y * tilesize));
}
}
public static boolean validPlace(Team team, int x, int y, Block type, int rotation){

View File

@ -9,6 +9,7 @@ import io.anuke.mindustry.entities.effect.Rubble;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.graphics.Layer;
import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.mindustry.resource.Recipe;
import io.anuke.mindustry.world.BarType;
import io.anuke.mindustry.world.Block;
@ -96,5 +97,6 @@ public class BuildBlock extends Block {
public Block result;
public Recipe recipe;
public float progress = 0.05f;
public ItemStack[] stacks;
}
}