Recipe class removed completely
This commit is contained in:
@@ -60,7 +60,7 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
@Override
|
||||
public boolean isDrawing(){
|
||||
return mode != none || recipe != null;
|
||||
return mode != none || block != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,30 +70,30 @@ public class DesktopInput extends InputHandler{
|
||||
int cursorY = tileY(Core.input.mouseY());
|
||||
|
||||
//draw selection(s)
|
||||
if(mode == placing && recipe != null){
|
||||
if(mode == placing && block != null){
|
||||
NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursorX, cursorY, rotation, true, maxLength);
|
||||
|
||||
for(int i = 0; i <= result.getLength(); i += recipe.result.size){
|
||||
for(int i = 0; i <= result.getLength(); i += block.size){
|
||||
int x = selectX + i * Mathf.sign(cursorX - selectX) * Mathf.num(result.isX());
|
||||
int y = selectY + i * Mathf.sign(cursorY - selectY) * Mathf.num(!result.isX());
|
||||
|
||||
if(i + recipe.result.size > result.getLength() && recipe.result.rotate){
|
||||
Draw.color(!validPlace(x, y, recipe.result, result.rotation) ? Palette.removeBack : Palette.accentBack);
|
||||
if(i + block.size > result.getLength() && block.rotate){
|
||||
Draw.color(!validPlace(x, y, block, result.rotation) ? Palette.removeBack : Palette.accentBack);
|
||||
Draw.rect(Core.atlas.find("place-arrow"),
|
||||
x * tilesize + recipe.result.offset(),
|
||||
y * tilesize + recipe.result.offset() - 1,
|
||||
x * tilesize + block.offset(),
|
||||
y * tilesize + block.offset() - 1,
|
||||
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
||||
Core.atlas.find("place-arrow").getHeight() * Draw.scl, result.rotation * 90 - 90);
|
||||
|
||||
Draw.color(!validPlace(x, y, recipe.result, result.rotation) ? Palette.remove : Palette.accent);
|
||||
Draw.color(!validPlace(x, y, block, result.rotation) ? Palette.remove : Palette.accent);
|
||||
Draw.rect(Core.atlas.find("place-arrow"),
|
||||
x * tilesize + recipe.result.offset(),
|
||||
y * tilesize + recipe.result.offset(),
|
||||
x * tilesize + block.offset(),
|
||||
y * tilesize + block.offset(),
|
||||
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
||||
Core.atlas.find("place-arrow").getHeight() * Draw.scl, result.rotation * 90 - 90);
|
||||
}
|
||||
|
||||
drawPlace(x, y, recipe.result, result.rotation);
|
||||
drawPlace(x, y, block, result.rotation);
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
@@ -119,23 +119,23 @@ public class DesktopInput extends InputHandler{
|
||||
Draw.color(Palette.remove);
|
||||
Lines.rect(result.x, result.y, result.x2 - result.x, result.y2 - result.y);
|
||||
}else if(isPlacing()){
|
||||
if(recipe.result.rotate){
|
||||
Draw.color(!validPlace(cursorX, cursorY, recipe.result, rotation) ? Palette.removeBack : Palette.accentBack);
|
||||
if(block.rotate){
|
||||
Draw.color(!validPlace(cursorX, cursorY, block, rotation) ? Palette.removeBack : Palette.accentBack);
|
||||
Draw.rect(Core.atlas.find("place-arrow"),
|
||||
cursorX * tilesize + recipe.result.offset(),
|
||||
cursorY * tilesize + recipe.result.offset() - 1,
|
||||
cursorX * tilesize + block.offset(),
|
||||
cursorY * tilesize + block.offset() - 1,
|
||||
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
||||
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
|
||||
|
||||
Draw.color(!validPlace(cursorX, cursorY, recipe.result, rotation) ? Palette.remove : Palette.accent);
|
||||
Draw.color(!validPlace(cursorX, cursorY, block, rotation) ? Palette.remove : Palette.accent);
|
||||
Draw.rect(Core.atlas.find("place-arrow"),
|
||||
cursorX * tilesize + recipe.result.offset(),
|
||||
cursorY * tilesize + recipe.result.offset(),
|
||||
cursorX * tilesize + block.offset(),
|
||||
cursorY * tilesize + block.offset(),
|
||||
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
||||
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
|
||||
}
|
||||
drawPlace(cursorX, cursorY, recipe.result, rotation);
|
||||
recipe.result.drawPlace(cursorX, cursorY, rotation, validPlace(cursorX, cursorY, recipe.result, rotation));
|
||||
drawPlace(cursorX, cursorY, block, rotation);
|
||||
block.drawPlace(cursorX, cursorY, rotation, validPlace(cursorX, cursorY, block, rotation));
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
@@ -234,13 +234,13 @@ public class DesktopInput extends InputHandler{
|
||||
}else if(!ui.chatfrag.chatOpen()){ //if it's out of bounds, shooting is just fine
|
||||
player.isShooting = true;
|
||||
}
|
||||
}else if(Core.input.keyTap(Binding.deselect) && (recipe != null || mode != none || player.isBuilding()) &&
|
||||
}else if(Core.input.keyTap(Binding.deselect) && (block != null || mode != none || player.isBuilding()) &&
|
||||
!(player.getCurrentRequest() != null && player.getCurrentRequest().breaking && Core.keybinds.get(Binding.deselect) == Core.keybinds.get(Binding.break_block))){
|
||||
if(recipe == null){
|
||||
if(block == null){
|
||||
player.clearBuilding();
|
||||
}
|
||||
|
||||
recipe = null;
|
||||
block = null;
|
||||
mode = none;
|
||||
}else if(Core.input.keyTap(Binding.break_block) && !Core.scene.hasMouse()){
|
||||
//is recalculated because setting the mode to breaking removes potential multiblock cursor offset
|
||||
@@ -252,10 +252,10 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
if(Core.input.keyRelease(Binding.break_block) || Core.input.keyRelease(Binding.select)){
|
||||
|
||||
if(mode == placing && recipe != null){ //touch up while placing, place everything in selection
|
||||
if(mode == placing && block != null){ //touch up while placing, place everything in selection
|
||||
NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursorX, cursorY, rotation, true, maxLength);
|
||||
|
||||
for(int i = 0; i <= result.getLength(); i += recipe.result.size){
|
||||
for(int i = 0; i <= result.getLength(); i += block.size){
|
||||
int x = selectX + i * Mathf.sign(cursorX - selectX) * Mathf.num(result.isX());
|
||||
int y = selectY + i * Mathf.sign(cursorY - selectY) * Mathf.num(!result.isX());
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.ValidateException;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.fragments.OverlayFragment;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Build;
|
||||
@@ -41,7 +40,7 @@ public abstract class InputHandler implements InputProcessor{
|
||||
public final Player player;
|
||||
public final OverlayFragment frag = new OverlayFragment(this);
|
||||
|
||||
public Recipe recipe;
|
||||
public Block block;
|
||||
public int rotation;
|
||||
public boolean droppingItem;
|
||||
|
||||
@@ -199,7 +198,7 @@ public abstract class InputHandler implements InputProcessor{
|
||||
|
||||
if(!consumed && player.isBuilding()){
|
||||
player.clearBuilding();
|
||||
recipe = null;
|
||||
block = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -245,7 +244,7 @@ public abstract class InputHandler implements InputProcessor{
|
||||
int tileX(float cursorX){
|
||||
Vector2 vec = Core.input.mouseWorld(cursorX, 0);
|
||||
if(selectedBlock()){
|
||||
vec.sub(recipe.result.offset(), recipe.result.offset());
|
||||
vec.sub(block.offset(), block.offset());
|
||||
}
|
||||
return world.toTile(vec.x);
|
||||
}
|
||||
@@ -253,7 +252,7 @@ public abstract class InputHandler implements InputProcessor{
|
||||
int tileY(float cursorY){
|
||||
Vector2 vec = Core.input.mouseWorld(0, cursorY);
|
||||
if(selectedBlock()){
|
||||
vec.sub(recipe.result.offset(), recipe.result.offset());
|
||||
vec.sub(block.offset(), block.offset());
|
||||
}
|
||||
return world.toTile(vec.y);
|
||||
}
|
||||
@@ -263,7 +262,7 @@ public abstract class InputHandler implements InputProcessor{
|
||||
}
|
||||
|
||||
public boolean isPlacing(){
|
||||
return recipe != null;
|
||||
return block != null;
|
||||
}
|
||||
|
||||
public float mouseAngle(float x, float y){
|
||||
@@ -276,7 +275,7 @@ public abstract class InputHandler implements InputProcessor{
|
||||
}
|
||||
|
||||
public boolean canShoot(){
|
||||
return recipe == null && !Core.scene.hasMouse() && !onConfigurable() && !isDroppingItem();
|
||||
return block == null && !Core.scene.hasMouse() && !onConfigurable() && !isDroppingItem();
|
||||
}
|
||||
|
||||
public boolean onConfigurable(){
|
||||
@@ -309,8 +308,8 @@ public abstract class InputHandler implements InputProcessor{
|
||||
}
|
||||
|
||||
public void tryPlaceBlock(int x, int y){
|
||||
if(recipe != null && validPlace(x, y, recipe.result, rotation) && cursorNear()){
|
||||
placeBlock(x, y, recipe, rotation);
|
||||
if(block != null && validPlace(x, y, block, rotation) && cursorNear()){
|
||||
placeBlock(x, y, block, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,8 +328,8 @@ public abstract class InputHandler implements InputProcessor{
|
||||
return Build.validBreak(player.getTeam(), x, y) && Mathf.dst(player.x, player.y, x * tilesize, y * tilesize) < Player.placeDistance;
|
||||
}
|
||||
|
||||
public void placeBlock(int x, int y, Recipe recipe, int rotation){
|
||||
player.addBuildRequest(new BuildRequest(x, y, rotation, recipe));
|
||||
public void placeBlock(int x, int y, Block block, int rotation){
|
||||
player.addBuildRequest(new BuildRequest(x, y, rotation, block));
|
||||
}
|
||||
|
||||
public void breakBlock(int x, int y){
|
||||
|
||||
@@ -30,7 +30,6 @@ import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Shaders;
|
||||
import io.anuke.mindustry.input.PlaceUtils.NormalizeDrawResult;
|
||||
import io.anuke.mindustry.input.PlaceUtils.NormalizeResult;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Block.Icon;
|
||||
@@ -73,7 +72,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
/** Current place mode. */
|
||||
private PlaceMode mode = none;
|
||||
/** Whether no recipe was available when switching to break mode. */
|
||||
private Recipe lastRecipe;
|
||||
private Block lastBlock;
|
||||
/** Last placed request. Used for drawing block overlay. */
|
||||
private PlaceRequest lastPlaced;
|
||||
|
||||
@@ -121,8 +120,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
if(other == null || req.remove) continue;
|
||||
|
||||
r1.setSize(req.recipe.result.size * tilesize);
|
||||
r1.setCenter(other.worldx() + req.recipe.result.offset(), other.worldy() + req.recipe.result.offset());
|
||||
r1.setSize(req.block.size * tilesize);
|
||||
r1.setCenter(other.worldx() + req.block.offset(), other.worldy() + req.block.offset());
|
||||
|
||||
if(r2.overlaps(r1)){
|
||||
return true;
|
||||
@@ -142,8 +141,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
if(other == null) continue;
|
||||
|
||||
if(!req.remove){
|
||||
r1.setSize(req.recipe.result.size * tilesize);
|
||||
r1.setCenter(other.worldx() + req.recipe.result.offset(), other.worldy() + req.recipe.result.offset());
|
||||
r1.setSize(req.block.size * tilesize);
|
||||
r1.setCenter(other.worldx() + req.block.offset(), other.worldy() + req.block.offset());
|
||||
|
||||
if(r2.overlaps(r1)){
|
||||
return req;
|
||||
@@ -171,8 +170,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
if(!request.remove){
|
||||
//draw placing request
|
||||
float offset = request.recipe.result.offset();
|
||||
TextureRegion region = request.recipe.result.icon(Icon.full);
|
||||
float offset = request.block.offset();
|
||||
TextureRegion region = request.block.icon(Icon.full);
|
||||
|
||||
Draw.alpha(Mathf.clamp((1f - request.scale) / 0.5f));
|
||||
Draw.tint(Color.WHITE, Palette.breakInvalid, request.redness);
|
||||
@@ -180,7 +179,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
Draw.rect(region, tile.worldx() + offset, tile.worldy() + offset,
|
||||
region.getWidth() * request.scale * Draw.scl,
|
||||
region.getHeight() * request.scale * Draw.scl,
|
||||
request.recipe.result.rotate ? request.rotation * 90 : 0);
|
||||
request.block.rotate ? request.rotation * 90 : 0);
|
||||
}else{
|
||||
float rad = (tile.block().size * tilesize / 2f - 1) * request.scale;
|
||||
Draw.alpha(0f);
|
||||
@@ -219,8 +218,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
table.left().margin(0f).defaults().size(48f);
|
||||
|
||||
table.addImageButton("icon-break", "clear-toggle-partial", 16 * 2f, () -> {
|
||||
mode = mode == breaking ? recipe == null ? none : placing : breaking;
|
||||
lastRecipe = recipe;
|
||||
mode = mode == breaking ? block == null ? none : placing : breaking;
|
||||
lastBlock = block;
|
||||
if(mode == breaking){
|
||||
showGuide("deconstruction");
|
||||
}
|
||||
@@ -230,13 +229,13 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
table.addImageButton("icon-cancel", "clear-partial", 16 * 2f, () -> {
|
||||
player.clearBuilding();
|
||||
mode = none;
|
||||
recipe = null;
|
||||
}).visible(() -> player.isBuilding() || recipe != null || mode == breaking);
|
||||
block = null;
|
||||
}).visible(() -> player.isBuilding() || block != null || mode == breaking);
|
||||
|
||||
//rotate button
|
||||
table.addImageButton("icon-arrow", "clear-partial", 16 * 2f, () -> rotation = Mathf.mod(rotation + 1, 4))
|
||||
.update(i -> i.getImage().setRotationOrigin(rotation * 90, Align.center))
|
||||
.visible(() -> recipe != null && recipe.result.rotate);
|
||||
.visible(() -> block != null && block.rotate);
|
||||
|
||||
//confirm button
|
||||
table.addImageButton("icon-check", "clear-partial", 16 * 2f, () -> {
|
||||
@@ -247,10 +246,10 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
if(tile != null){
|
||||
if(!request.remove){
|
||||
rotation = request.rotation;
|
||||
Recipe before = recipe;
|
||||
recipe = request.recipe;
|
||||
Block before = block;
|
||||
block = request.block;
|
||||
tryPlaceBlock(tile.x, tile.y);
|
||||
recipe = before;
|
||||
block = before;
|
||||
}else{
|
||||
tryBreakBlock(tile.x, tile.y);
|
||||
}
|
||||
@@ -299,7 +298,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
if(tile == null) continue;
|
||||
|
||||
if((!request.remove && validPlace(tile.x, tile.y, request.recipe.result, request.rotation))
|
||||
if((!request.remove && validPlace(tile.x, tile.y, request.block, request.rotation))
|
||||
|| (request.remove && validBreak(tile.x, tile.y))){
|
||||
request.scale = Mathf.lerpDelta(request.scale, 1f, 0.2f);
|
||||
request.redness = Mathf.lerpDelta(request.redness, 0f, 0.2f);
|
||||
@@ -312,8 +311,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
drawRequest(request);
|
||||
|
||||
//draw last placed request
|
||||
if(!request.remove && request == lastPlaced && request.recipe != null){
|
||||
request.recipe.result.drawPlace(tile.x, tile.y, rotation, validPlace(tile.x, tile.y, request.recipe.result, rotation));
|
||||
if(!request.remove && request == lastPlaced && request.block != null){
|
||||
request.block.drawPlace(tile.x, tile.y, rotation, validPlace(tile.x, tile.y, request.block, rotation));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,32 +326,32 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
int tileY = tileY(Core.input.mouseY());
|
||||
|
||||
//draw placing
|
||||
if(mode == placing && recipe != null){
|
||||
NormalizeDrawResult dresult = PlaceUtils.normalizeDrawArea(recipe.result, lineStartX, lineStartY, tileX, tileY, true, maxLength, lineScale);
|
||||
if(mode == placing && block != null){
|
||||
NormalizeDrawResult dresult = PlaceUtils.normalizeDrawArea(block, lineStartX, lineStartY, tileX, tileY, true, maxLength, lineScale);
|
||||
|
||||
Lines.rect(dresult.x, dresult.y, dresult.x2 - dresult.x, dresult.y2 - dresult.y);
|
||||
|
||||
NormalizeResult result = PlaceUtils.normalizeArea(lineStartX, lineStartY, tileX, tileY, rotation, true, maxLength);
|
||||
|
||||
//go through each cell and draw the block to place if valid
|
||||
for(int i = 0; i <= result.getLength(); i += recipe.result.size){
|
||||
for(int i = 0; i <= result.getLength(); i += block.size){
|
||||
int x = lineStartX + i * Mathf.sign(tileX - lineStartX) * Mathf.num(result.isX());
|
||||
int y = lineStartY + i * Mathf.sign(tileY - lineStartY) * Mathf.num(!result.isX());
|
||||
|
||||
if(!checkOverlapPlacement(x, y, recipe.result) && validPlace(x, y, recipe.result, result.rotation)){
|
||||
if(!checkOverlapPlacement(x, y, block) && validPlace(x, y, block, result.rotation)){
|
||||
Draw.color();
|
||||
|
||||
TextureRegion region = recipe.result.icon(Icon.full);
|
||||
TextureRegion region = block.icon(Icon.full);
|
||||
|
||||
Draw.rect(region, x * tilesize + recipe.result.offset(), y * tilesize + recipe.result.offset(),
|
||||
Draw.rect(region, x * tilesize + block.offset(), y * tilesize + block.offset(),
|
||||
region.getWidth() * lineScale * Draw.scl,
|
||||
region.getHeight() * lineScale * Draw.scl,
|
||||
recipe.result.rotate ? result.rotation * 90 : 0);
|
||||
block.rotate ? result.rotation * 90 : 0);
|
||||
}else{
|
||||
Draw.color(Palette.removeBack);
|
||||
Lines.square(x * tilesize + recipe.result.offset(), y * tilesize + recipe.result.offset() - 1, recipe.result.size * tilesize / 2f);
|
||||
Lines.square(x * tilesize + block.offset(), y * tilesize + block.offset() - 1, block.size * tilesize / 2f);
|
||||
Draw.color(Palette.remove);
|
||||
Lines.square(x * tilesize + recipe.result.offset(), y * tilesize + recipe.result.offset(), recipe.result.size * tilesize / 2f);
|
||||
Lines.square(x * tilesize + block.offset(), y * tilesize + block.offset(), block.size * tilesize / 2f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +440,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
int tileX = tileX(screenX);
|
||||
int tileY = tileY(screenY);
|
||||
|
||||
if(mode == placing && recipe != null){
|
||||
if(mode == placing && block != null){
|
||||
|
||||
//normalize area
|
||||
NormalizeResult result = PlaceUtils.normalizeArea(lineStartX, lineStartY, tileX, tileY, rotation, true, 100);
|
||||
@@ -449,12 +448,12 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
rotation = result.rotation;
|
||||
|
||||
//place blocks on line
|
||||
for(int i = 0; i <= result.getLength(); i += recipe.result.size){
|
||||
for(int i = 0; i <= result.getLength(); i += block.size){
|
||||
int x = lineStartX + i * Mathf.sign(tileX - lineStartX) * Mathf.num(result.isX());
|
||||
int y = lineStartY + i * Mathf.sign(tileY - lineStartY) * Mathf.num(!result.isX());
|
||||
|
||||
if(!checkOverlapPlacement(x, y, recipe.result) && validPlace(x, y, recipe.result, result.rotation)){
|
||||
PlaceRequest request = new PlaceRequest(x * tilesize + recipe.result.offset(), y * tilesize + recipe.result.offset(), recipe, result.rotation);
|
||||
if(!checkOverlapPlacement(x, y, block) && validPlace(x, y, block, result.rotation)){
|
||||
PlaceRequest request = new PlaceRequest(x * tilesize + block.offset(), y * tilesize + block.offset(), block, result.rotation);
|
||||
request.scale = 1f;
|
||||
selection.add(request);
|
||||
}
|
||||
@@ -517,8 +516,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
if(mode == breaking){
|
||||
Effects.effect(Fx.tapBlock, cursor.worldx(), cursor.worldy(), 1f);
|
||||
}else if(recipe != null){
|
||||
Effects.effect(Fx.tapBlock, cursor.worldx() + recipe.result.offset(), cursor.worldy() + recipe.result.offset(), recipe.result.size);
|
||||
}else if(block != null){
|
||||
Effects.effect(Fx.tapBlock, cursor.worldx() + block.offset(), cursor.worldy() + block.offset(), block.size);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -541,9 +540,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
//remove if request present
|
||||
if(hasRequest(cursor)){
|
||||
removeRequest(getRequest(cursor));
|
||||
}else if(mode == placing && isPlacing() && validPlace(cursor.x, cursor.y, recipe.result, rotation) && !checkOverlapPlacement(cursor.x, cursor.y, recipe.result)){
|
||||
}else if(mode == placing && isPlacing() && validPlace(cursor.x, cursor.y, block, rotation) && !checkOverlapPlacement(cursor.x, cursor.y, block)){
|
||||
//add to selection queue if it's a valid place position
|
||||
selection.add(lastPlaced = new PlaceRequest(cursor.worldx() + recipe.result.offset(), cursor.worldy() + recipe.result.offset(), recipe, rotation));
|
||||
selection.add(lastPlaced = new PlaceRequest(cursor.worldx() + block.offset(), cursor.worldy() + block.offset(), block, rotation));
|
||||
}else if(mode == breaking && validBreak(cursor.target().x, cursor.target().y) && !hasRequest(cursor.target())){
|
||||
//add to selection queue if it's a valid BREAK position
|
||||
cursor = cursor.target();
|
||||
@@ -590,27 +589,27 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
selection.clear();
|
||||
}
|
||||
|
||||
if(lineMode && mode == placing && recipe == null){
|
||||
if(lineMode && mode == placing && block == null){
|
||||
lineMode = false;
|
||||
}
|
||||
|
||||
//if there is no mode and there's a recipe, switch to placing
|
||||
if(recipe != null && mode == none){
|
||||
if(block != null && mode == none){
|
||||
mode = placing;
|
||||
}
|
||||
|
||||
if(recipe != null){
|
||||
if(block != null){
|
||||
showGuide("construction");
|
||||
}
|
||||
|
||||
if(recipe == null && mode == placing){
|
||||
if(block == null && mode == placing){
|
||||
mode = none;
|
||||
}
|
||||
|
||||
//automatically switch to placing after a new recipe is selected
|
||||
if(lastRecipe != recipe && mode == breaking && recipe != null){
|
||||
if(lastBlock != block && mode == breaking && block != null){
|
||||
mode = placing;
|
||||
lastRecipe = recipe;
|
||||
lastBlock = block;
|
||||
}
|
||||
|
||||
if(lineMode){
|
||||
@@ -712,7 +711,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
class PlaceRequest{
|
||||
float x, y;
|
||||
Recipe recipe;
|
||||
Block block;
|
||||
int rotation;
|
||||
boolean remove;
|
||||
|
||||
@@ -720,10 +719,10 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
float scale;
|
||||
float redness;
|
||||
|
||||
PlaceRequest(float x, float y, Recipe recipe, int rotation){
|
||||
PlaceRequest(float x, float y, Block block, int rotation){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.recipe = recipe;
|
||||
this.block = block;
|
||||
this.rotation = rotation;
|
||||
this.remove = false;
|
||||
}
|
||||
@@ -735,7 +734,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
}
|
||||
|
||||
Tile tile(){
|
||||
return world.tileWorld(x - (recipe == null ? 0 : recipe.result.offset()), y - (recipe == null ? 0 : recipe.result.offset()));
|
||||
return world.tileWorld(x - (block == null ? 0 : block.offset()), y - (block == null ? 0 : block.offset()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user