From 70f8eb59a71ea8afdf4ba5a9cddd70a37cd8439e Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Sat, 19 Feb 2022 15:43:58 +0800 Subject: [PATCH] replace Vector2 with GridPoint2 (originally Point - awt) --- .../adventure/stage/WorldBackground.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/forge-gui-mobile/src/forge/adventure/stage/WorldBackground.java b/forge-gui-mobile/src/forge/adventure/stage/WorldBackground.java index 56985ccfb20..feda5ccab04 100644 --- a/forge-gui-mobile/src/forge/adventure/stage/WorldBackground.java +++ b/forge-gui-mobile/src/forge/adventure/stage/WorldBackground.java @@ -3,7 +3,7 @@ package forge.adventure.stage; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Batch; -import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.math.GridPoint2; import com.badlogic.gdx.scenes.scene2d.Actor; import forge.adventure.world.WorldSave; @@ -37,36 +37,36 @@ public class WorldBackground extends Actor { if (chunks == null) { initialize(); } - Vector2 pos = translateFromWorldToChunk(playerX, playerY); + GridPoint2 pos = translateFromWorldToChunk(playerX, playerY); if (currentChunkX != pos.x || currentChunkY != pos.y) { - int xDiff = currentChunkX - (int)pos.x; - int yDiff = currentChunkY - (int)pos.y; - ArrayList points = new ArrayList<>(); + int xDiff = currentChunkX - pos.x; + int yDiff = currentChunkY - pos.y; + ArrayList points = new ArrayList(); for (int x = -1; x < 2; x++) { for (int y = -1; y < 2; y++) { - points.add(new Vector2(pos.x + x, pos.y + y)); + points.add(new GridPoint2(pos.x + x, pos.y + y)); } } for (int x = -1; x < 2; x++) { for (int y = -1; y < 2; y++) { - Vector2 point = new Vector2(currentChunkX + x, currentChunkY + y); + GridPoint2 point = new GridPoint2(currentChunkX + x, currentChunkY + y); if (points.contains(point))// old Point is part of new points { points.remove(point); } else { if (point.y < 0 || point.x < 0 || point.y >= chunks[0].length || point.x >= chunks.length) continue; - unLoadChunk((int)point.x, (int)point.y); + unLoadChunk(point.x, point.y); } } } - for (Vector2 point : points) { + for (GridPoint2 point : points) { if (point.y < 0 || point.x < 0 || point.y >= chunks[0].length || point.x >= chunks.length) continue; - loadChunk((int)point.x, (int)point.y); + loadChunk(point.x, point.y); } - currentChunkX = (int)pos.x; - currentChunkY = (int)pos.y; + currentChunkX = pos.x; + currentChunkY = pos.y; } batch.disableBlending(); for (int x = -1; x < 2; x++) { @@ -75,7 +75,7 @@ public class WorldBackground extends Actor { continue; - batch.draw(getChunkTexture((int)pos.x + x, (int)pos.y + y), transChunkToWorld((int)pos.x + x), transChunkToWorld((int)pos.y + y)); + batch.draw(getChunkTexture(pos.x + x, pos.y + y), transChunkToWorld(pos.x + x), transChunkToWorld(pos.y + y)); } } batch.enableBlending(); @@ -154,10 +154,10 @@ public class WorldBackground extends Actor { for (int x = -1; x < 2; x++) { for (int y = -1; y < 2; y++) { - Vector2 point = new Vector2(currentChunkX + x, currentChunkY + y); + GridPoint2 point = new GridPoint2(currentChunkX + x, currentChunkY + y); if (point.y < 0 || point.x < 0 || point.y >= chunks[0].length || point.x >= chunks.length) continue; - loadChunk((int)point.x, (int)point.y); + loadChunk(point.x, point.y); } } } @@ -171,10 +171,10 @@ public class WorldBackground extends Actor { return xy * tileSize * chunkSize; } - Vector2 translateFromWorldToChunk(float x, float y) { + GridPoint2 translateFromWorldToChunk(float x, float y) { float worldWidthTiles = x / tileSize; float worldHeightTiles = y / tileSize; - return new Vector2((int) worldWidthTiles / chunkSize, (int) worldHeightTiles / chunkSize); + return new GridPoint2((int) worldWidthTiles / chunkSize, (int) worldHeightTiles / chunkSize); } public void setPlayerPos(float x, float y) {