Broke 90% of all code

This commit is contained in:
Anuken
2018-01-27 14:43:35 -05:00
parent 93cd497c8d
commit 78c8dc4902
36 changed files with 582 additions and 745 deletions

View File

@@ -31,14 +31,14 @@ public class GestureHandler extends GestureAdapter{
public boolean tap (float x, float y, int count, int button) {
if(ui.hasMouse() || input.brokeBlock) return false;
if(!control.getInput().placeMode.pan || control.getInput().recipe == null){
if(!control.input().placeMode.pan || control.input().recipe == null){
input.mousex = x;
input.mousey = y;
if(control.getInput().recipe == null)
control.getInput().breakMode.tapped(input.getBlockX(), input.getBlockY());
if(control.input().recipe == null)
control.input().breakMode.tapped(input.getBlockX(), input.getBlockY());
else
control.getInput().placeMode.tapped(input.getBlockX(), input.getBlockY());
control.input().placeMode.tapped(input.getBlockX(), input.getBlockY());
}
return false;
}
@@ -47,13 +47,13 @@ public class GestureHandler extends GestureAdapter{
public boolean pan(float x, float y, float deltaX, float deltaY){
if(Vars.control.showCursor() && !Inputs.keyDown("select")) return false;
if(!Vars.control.showCursor() && !(control.getInput().recipe != null && Vars.control.hasItems(control.getInput().recipe.requirements) && control.getInput().placeMode.lockCamera) &&
!(control.getInput().recipe == null && control.getInput().breakMode.lockCamera)){
if(!Vars.control.showCursor() && !(control.input().recipe != null && Vars.control.hasItems(control.input().recipe.requirements) && control.input().placeMode.lockCamera) &&
!(control.input().recipe == null && control.input().breakMode.lockCamera)){
float dx = deltaX*Core.camera.zoom/Core.cameraScale, dy = deltaY*Core.camera.zoom/Core.cameraScale;
player.x -= dx;
player.y += dy;
player.targetAngle = Mathf.atan2(dx, -dy);
}else if(control.getInput().placeMode.lockCamera && (control.getInput().placeMode.pan && control.getInput().recipe != null)){
}else if(control.input().placeMode.lockCamera && (control.input().placeMode.pan && control.input().recipe != null)){
input.mousex += deltaX;
input.mousey += deltaY;
}
@@ -63,7 +63,7 @@ public class GestureHandler extends GestureAdapter{
@Override
public boolean pinch (Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) {
if(control.getInput().recipe == null && !control.getInput().breakMode.lockCamera)
if(control.input().recipe == null && !control.input().breakMode.lockCamera)
return false;
if(pinch1.x < 0){

View File

@@ -129,7 +129,7 @@ public abstract class InputHandler extends InputAdapter{
int rotation = Vars.control.getTutorial().getPlaceRotation();
Block block = Vars.control.getTutorial().getPlaceBlock();
if(type != block || point.x != x - control.getCore().x || point.y != y - control.getCore().y
if(type != block || point.x != x - world.getCore().x || point.y != y - world.getCore().y
|| (rotation != -1 && rotation != this.rotation)){
return false;
}
@@ -173,7 +173,7 @@ public abstract class InputHandler extends InputAdapter{
int rotation = Vars.control.getTutorial().getPlaceRotation();
Block block = Vars.control.getTutorial().getPlaceBlock();
if(block != Blocks.air || point.x != x - control.getCore().x || point.y != y - control.getCore().y
if(block != Blocks.air || point.x != x - world.getCore().x || point.y != y - world.getCore().y
|| (rotation != -1 && rotation != this.rotation)){
return false;
}

View File

@@ -30,23 +30,23 @@ public enum PlaceMode{
float x = tilex * Vars.tilesize;
float y = tiley * Vars.tilesize;
boolean valid = control.getInput().validPlace(tilex, tiley, control.getInput().recipe.result) && (android || control.getInput().cursorNear());
boolean valid = control.input().validPlace(tilex, tiley, control.input().recipe.result) && (android || control.input().cursorNear());
Vector2 offset = control.getInput().recipe.result.getPlaceOffset();
Vector2 offset = control.input().recipe.result.getPlaceOffset();
float si = MathUtils.sin(Timers.time() / 6f) + 1.5f;
Draw.color(valid ? Colors.get("place") : Colors.get("placeInvalid"));
Lines.stroke(2f);
Lines.crect(x + offset.x, y + offset.y, tilesize * control.getInput().recipe.result.width + si,
tilesize * control.getInput().recipe.result.height + si);
Lines.crect(x + offset.x, y + offset.y, tilesize * control.input().recipe.result.width + si,
tilesize * control.input().recipe.result.height + si);
control.getInput().recipe.result.drawPlace(tilex, tiley, control.getInput().rotation, valid);
control.input().recipe.result.drawPlace(tilex, tiley, control.input().rotation, valid);
Lines.stroke(2f);
if(control.getInput().recipe.result.rotate){
if(control.input().recipe.result.rotate){
Draw.color(Colors.get("placeRotate"));
Tmp.v1.set(7, 0).rotate(control.getInput().rotation * 90);
Tmp.v1.set(7, 0).rotate(control.input().rotation * 90);
Lines.line(x, y, x + Tmp.v1.x, y + Tmp.v1.y);
}
@@ -57,7 +57,7 @@ public enum PlaceMode{
}
public void tapped(int tilex, int tiley){
control.getInput().tryPlaceBlock(tilex, tiley, true);
control.input().tryPlaceBlock(tilex, tiley, true);
}
},
touch{
@@ -69,7 +69,7 @@ public enum PlaceMode{
}
public void tapped(int x, int y){
control.getInput().tryPlaceBlock(x, y, true);
control.input().tryPlaceBlock(x, y, true);
}
},
none{
@@ -89,12 +89,12 @@ public enum PlaceMode{
public void draw(int tilex, int tiley, int endx, int endy){
Tile tile = world.tile(tilex, tiley);
if(tile != null && control.getInput().validBreak(tilex, tiley)){
if(tile != null && control.input().validBreak(tilex, tiley)){
if(tile.isLinked())
tile = tile.getLinked();
float fract = control.getInput().breaktime / tile.getBreakTime();
float fract = control.input().breaktime / tile.getBreakTime();
if(android && control.getInput().breaktime > 0){
if(android && control.input().breaktime > 0){
Draw.color(Colors.get("breakStart"), Colors.get("break"), fract);
Lines.poly(tile.drawx(), tile.drawy(), 25, 4 + (1f - fract) * 26);
}
@@ -112,7 +112,7 @@ public enum PlaceMode{
}
public void tapped(int x, int y){
control.getInput().tryDeleteBlock(x, y, true);
control.input().tryDeleteBlock(x, y, true);
}
},
areaDelete{
@@ -155,7 +155,7 @@ public enum PlaceMode{
Tile tile = Vars.world.tile(cx, cy);
if(tile != null && tile.getLinked() != null)
tile = tile.getLinked();
if(tile != null && control.getInput().validBreak(tile.x, tile.y)){
if(tile != null && control.input().validBreak(tile.x, tile.y)){
Lines.crect(tile.drawx(), tile.drawy(),
tile.block().width * t, tile.block().height * t);
}
@@ -163,7 +163,7 @@ public enum PlaceMode{
}
Lines.stroke(2f);
Draw.color(control.getInput().cursorNear() ? Colors.get("break") : Colors.get("breakInvalid"));
Draw.color(control.input().cursorNear() ? Colors.get("break") : Colors.get("breakInvalid"));
Lines.rect(x, y, x2 - x, y2 - y);
Draw.alpha(0.3f);
Draw.crect("blank", x, y, x2 - x, y2 - y);
@@ -192,7 +192,7 @@ public enum PlaceMode{
for(int cx = tilex; cx <= endx; cx ++){
for(int cy = tiley; cy <= endy; cy ++){
if(control.getInput().tryDeleteBlock(cx, cy, first)){
if(control.input().tryDeleteBlock(cx, cy, first)){
first = false;
}
}
@@ -247,7 +247,7 @@ public enum PlaceMode{
}
float t = Vars.tilesize;
Block block = control.getInput().recipe.result;
Block block = control.input().recipe.result;
Vector2 offset = block.getPlaceOffset();
process(tilex, tiley, endx, endy);
@@ -276,7 +276,7 @@ public enum PlaceMode{
cursor.draw(tilex, tiley, endx, endy);
}else{
Lines.stroke(2f);
Draw.color(control.getInput().cursorNear() ? Colors.get("place") : Colors.get("placeInvalid"));
Draw.color(control.input().cursorNear() ? Colors.get("place") : Colors.get("placeInvalid"));
Lines.rect(x, y, x2 - x, y2 - y);
Draw.alpha(0.3f);
Draw.crect("blank", x, y, x2 - x, y2 - y);
@@ -289,15 +289,15 @@ public enum PlaceMode{
int px = tx + cx * Mathf.sign(ex - tx),
py = ty + cy * Mathf.sign(ey - ty);
if(!control.getInput().validPlace(px, py, control.getInput().recipe.result)
|| !control.hasItems(control.getInput().recipe.requirements, amount)){
if(!control.input().validPlace(px, py, control.input().recipe.result)
|| !control.hasItems(control.input().recipe.requirements, amount)){
Lines.crect(px * t + offset.x, py * t + offset.y, t*block.width, t*block.height);
}
amount ++;
}
}
if(control.getInput().recipe.result.rotate){
if(control.input().recipe.result.rotate){
float cx = tx * t, cy = ty * t;
Draw.color(Colors.get("placeRotate"));
Tmp.v1.set(7, 0).rotate(rotation * 90);
@@ -310,12 +310,12 @@ public enum PlaceMode{
public void released(int tilex, int tiley, int endx, int endy){
process(tilex, tiley, endx, endy);
control.getInput().rotation = this.rotation;
control.input().rotation = this.rotation;
boolean first = true;
for(int x = 0; x <= Math.abs(this.endx - this.tilex); x ++){
for(int y = 0; y <= Math.abs(this.endy - this.tiley); y ++){
if(control.getInput().tryPlaceBlock(
if(control.input().tryPlaceBlock(
tilex + x * Mathf.sign(endx - tilex),
tiley + y * Mathf.sign(endy - tiley), first)){
first = false;
@@ -349,7 +349,7 @@ public enum PlaceMode{
else if(endy < tiley)
rotation = 3;
else
rotation = control.getInput().rotation;
rotation = control.input().rotation;
if(endx < tilex){
int t = endx;