Many internal changes

This commit is contained in:
Anuken
2020-03-04 13:32:31 -05:00
parent aeae286273
commit cf31293d7b
30 changed files with 283 additions and 290 deletions

View File

@@ -264,9 +264,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
int ox = schemOriginX(), oy = schemOriginY();
requests.each(req -> {
//rotate config position
if(req.config instanceof Point2){
int cx = ((Point2)req.config).x - req.originalX, cy = ((Point2)req.config).y - req.originalY;
req.pointConfig(p -> {
int cx = p.x - req.originalX, cy = p.y - req.originalY;
int lx = cx;
if(direction >= 0){
@@ -276,8 +275,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
cx = cy;
cy = -lx;
}
req.config = new Point2(cx + req.originalX, cy + req.originalY);
}
p.set(cx + req.originalX, cy + req.originalY);
});
//rotate actual request, centered on its multiblock position
float wx = (req.x - ox) * tilesize + req.block.offset(), wy = (req.y - oy) * tilesize + req.block.offset();
@@ -307,17 +306,17 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
req.y = (int)((value - req.block.offset()) / tilesize);
}
if(req.config instanceof Point2){
req.pointConfig(p -> {
int corigin = x ? req.originalWidth/2 : req.originalHeight/2;
int nvalue = -((x ? ((Point2)req.config).x : ((Point2)req.config).y) - corigin) + corigin;
int nvalue = -((x ? p.x : p.y) - corigin) + corigin;
if(x){
req.originalX = -(req.originalX - corigin) + corigin;
req.config = Pos.get(nvalue, ((Point2)req.config).y);
p.x = nvalue;
}else{
req.originalY = -(req.originalY - corigin) + corigin;
req.config = Pos.get(((Point2)req.config).x, nvalue);
p.y = nvalue;
}
}
});
//flip rotation
if(x == (req.rotation % 2 == 0)){
@@ -450,9 +449,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
for(BuildRequest req : requests){
if(req.block != null && validPlace(req.x, req.y, req.block, req.rotation)){
BuildRequest copy = req.copy();
if(copy.hasConfig && copy.config instanceof Point2){
copy.config = Pos.get(((Point2)copy.config).x + copy.x - copy.originalX, ((Point2)copy.config).x + copy.y - copy.originalY);
}
copy.pointConfig(p -> p.add(copy.x - copy.originalX, copy.y - copy.originalY));
player.builder().addBuild(copy);
}
}

View File

@@ -222,9 +222,7 @@ public class MobileInput extends InputHandler implements GestureListener{
BuildRequest other = getRequest(request.x, request.y, request.block.size, null);
BuildRequest copy = request.copy();
if(copy.hasConfig && copy.config instanceof Point2){
copy.config = Pos.get(((Point2)copy.config).x + copy.x - copy.originalX, ((Point2)copy.config).y + copy.y - copy.originalY);
}
copy.pointConfig(p -> p.add(copy.x - copy.originalX, copy.y - copy.originalY));
if(other == null){
player.builder().addBuild(copy);

View File

@@ -107,7 +107,7 @@ public class Placement{
found = true;
break;
}
closed.add(Pos.get(next.x, next.y));
closed.add(Point2.pack((int)next.x, (int)next.y));
for(Point2 point : Geometry.d4){
int newx = next.x + point.x, newy = next.y + point.y;
Tile child = world.tile(newx, newy);
@@ -129,11 +129,11 @@ public class Placement{
Tile current = end;
while(current != start && total++ < nodeLimit){
if(current == null) return false;
int newPos = parents.get(current.pos(), Pos.invalid);
int newPos = parents.get(current.pos(), -1);
if(newPos == Pos.invalid) return false;
if(newPos == -1) return false;
points.add(Pools.obtain(Point2.class, Point2::new).set(Pos.x(newPos), Pos.y(newPos)));
points.add(Pools.obtain(Point2.class, Point2::new).set(Point2.x(newPos), Point2.y(newPos)));
current = world.tile(newPos);
}