Fixed placement preview PR
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Sat Apr 21 15:14:36 EDT 2018
|
#Sat Apr 21 15:53:18 EDT 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=526
|
androidBuildCode=526
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
|
|||||||
@@ -270,26 +270,50 @@ public enum PlaceMode{
|
|||||||
cursor.draw(tilex, tiley, endx, endy);
|
cursor.draw(tilex, tiley, endx, endy);
|
||||||
}else{
|
}else{
|
||||||
Lines.stroke(2f);
|
Lines.stroke(2f);
|
||||||
Draw.color(control.input().cursorNear() ? Colors.get("place") : Colors.get("placeInvalid"));
|
Draw.color(control.input().cursorNear() ? "place" : "placeInvalid");
|
||||||
Lines.rect(x, y, x2 - x, y2 - y);
|
Lines.rect(x, y, x2 - x, y2 - y);
|
||||||
Draw.alpha(0.3f);
|
Draw.alpha(0.3f);
|
||||||
Draw.crect("blank", x, y, x2 - x, y2 - y);
|
Draw.crect("blank", x, y, x2 - x, y2 - y);
|
||||||
|
|
||||||
int amount = 1;
|
int amount = 1;
|
||||||
for(int cx = 0; cx <= Math.abs(endx - tilex); cx ++){
|
boolean isX = Math.abs(endx - tilex) >= Math.abs(endy - tiley);
|
||||||
for(int cy = 0; cy <= Math.abs(endy - tiley); cy ++){
|
|
||||||
|
for(int cx = 0; cx <= Math.abs(endx - tilex); cx += (isX ? 0 : 1)){
|
||||||
|
for(int cy = 0; cy <= Math.abs(endy - tiley); cy += (isX ? 1 : 0)){
|
||||||
|
|
||||||
int px = tx + cx * Mathf.sign(ex - tx),
|
int px = tx + cx * Mathf.sign(ex - tx),
|
||||||
py = ty + cy * Mathf.sign(ey - ty);
|
py = ty + cy * Mathf.sign(ey - ty);
|
||||||
|
|
||||||
renderer.getBlocks().handlePreview(control.input().recipe.result, control.input().recipe.result.rotate ? rotation * 90 : 0f, px * t + offset.x, py * t + offset.y, px, py);
|
//step by the block size if it's valid
|
||||||
|
if(control.input().validPlace(px, py, control.input().recipe.result) && state.inventory.hasItems(control.input().recipe.requirements, amount)){
|
||||||
|
|
||||||
if(!control.input().validPlace(px, py, control.input().recipe.result)
|
renderer.getBlocks().handlePreview(control.input().recipe.result, block.rotate ? rotation * 90 : 0f, px * t + offset.x, py * t + offset.y, px, py);
|
||||||
|| !state.inventory.hasItems(control.input().recipe.requirements, amount)){
|
|
||||||
Lines.stroke(2f);
|
if(isX){
|
||||||
Draw.color(Colors.get("placeInvalid"));
|
cx += block.width;
|
||||||
Lines.crect(px * t + offset.x, py * t + offset.y, t*block.width, t*block.height);
|
}else{
|
||||||
|
cy += block.width;
|
||||||
|
}
|
||||||
|
amount ++;
|
||||||
|
}else{ //otherwise, step by 1 until it is valid
|
||||||
|
if(control.input().cursorNear()){
|
||||||
|
Lines.stroke(2f);
|
||||||
|
Draw.color("placeInvalid");
|
||||||
|
Lines.crect(
|
||||||
|
px * t + (isX ? 0 : offset.x) + (ex < tx && isX ? t : 0) - (block.width == 3 && ex > tx && isX ? t : 0),
|
||||||
|
py * t + (isX ? offset.y : 0) + (ey < ty && !isX ? t : 0) - (block.height == 3 && ey > ty && !isX ? t : 0),
|
||||||
|
t*(isX ? 1 : block.width),
|
||||||
|
t*(isX ? block.height : 1));
|
||||||
|
Draw.color("place");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isX){
|
||||||
|
cx += 1;
|
||||||
|
}else{
|
||||||
|
cy += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
amount ++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user