From bddcdc0aa2f919237ed9b86b431283f070cad413 Mon Sep 17 00:00:00 2001 From: DeltaNedas Date: Fri, 16 Oct 2020 19:57:13 +0100 Subject: [PATCH 1/4] make planet stuff public, constructor protected --- .../mindustry/graphics/g3d/PlanetGrid.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/core/src/mindustry/graphics/g3d/PlanetGrid.java b/core/src/mindustry/graphics/g3d/PlanetGrid.java index e4972e3eb7..3f5ee0630a 100644 --- a/core/src/mindustry/graphics/g3d/PlanetGrid.java +++ b/core/src/mindustry/graphics/g3d/PlanetGrid.java @@ -22,15 +22,16 @@ public class PlanetGrid{ {5, 3, 10, 1, 4}, {2, 5, 4, 0, 11}, {3, 7, 6, 1, 8}, {7, 2, 9, 0, 6} }; - public final int size; - public final Ptile[] tiles; - public final Corner[] corners; - public final Edge[] edges; + public int size; + public Ptile[] tiles; + public Corner[] corners; + public Edge[] edges; - PlanetGrid(int size){ + //this is protected so if you want to make strange grids you should know what you're doing. + protected PlanetGrid(int size){ this.size = size; - tiles = new Ptile[Buildingount(size)]; + tiles = new Ptile[tileCount(size)]; for(int i = 0; i < tiles.length; i++){ tiles[i] = new Ptile(i, i < 12 ? 5 : 6); } @@ -67,7 +68,7 @@ public class PlanetGrid{ return result; } - static PlanetGrid initialGrid(){ + public static PlanetGrid initialGrid(){ PlanetGrid grid = new PlanetGrid(0); for(Ptile t : grid.tiles){ @@ -111,7 +112,7 @@ public class PlanetGrid{ return grid; } - static PlanetGrid subdividedGrid(PlanetGrid prev){ + public static PlanetGrid subdividedGrid(PlanetGrid prev){ PlanetGrid grid = new PlanetGrid(prev.size + 1); int prevTiles = prev.tiles.length; @@ -162,7 +163,7 @@ public class PlanetGrid{ return grid; } - static void addCorner(int id, PlanetGrid grid, int t1, int t2, int t3){ + public static void addCorner(int id, PlanetGrid grid, int t1, int t2, int t3){ Corner c = grid.corners[id]; Ptile[] t = {grid.tiles[t1], grid.tiles[t2], grid.tiles[t3]}; c.v.set(t[0].v).add(t[1].v).add(t[2].v).nor(); @@ -172,7 +173,7 @@ public class PlanetGrid{ } } - static void addEdge(int id, PlanetGrid grid, int t1, int t2){ + public static void addEdge(int id, PlanetGrid grid, int t1, int t2){ Edge e = grid.edges[id]; Ptile[] t = {grid.tiles[t1], grid.tiles[t2]}; Corner[] c = { @@ -186,36 +187,36 @@ public class PlanetGrid{ } } - static int pos(Ptile t, Ptile n){ + public static int pos(Ptile t, Ptile n){ for(int i = 0; i < t.edgeCount; i++) if(t.tiles[i] == n) return i; return -1; } - static int pos(Ptile t, Corner c){ + public static int pos(Ptile t, Corner c){ for(int i = 0; i < t.edgeCount; i++) if(t.corners[i] == c) return i; return -1; } - static int pos(Corner c, Corner n){ + public static int pos(Corner c, Corner n){ for(int i = 0; i < 3; i++) if(c.corners[i] == n) return i; return -1; } - static int Buildingount(int size){ + public static int tileCount(int size){ return 10 * Mathf.pow(3, size) + 2; } - static int cornerCount(int size){ + public static int cornerCount(int size){ return 20 * Mathf.pow(3, size); } - static int edgeCount(int size){ + public static int edgeCount(int size){ return 30 * Mathf.pow(3, size); } From fd54c66726c7152bb44bc0e7baec0391edbcdf3c Mon Sep 17 00:00:00 2001 From: DeltaNedas Date: Fri, 16 Oct 2020 22:26:50 +0100 Subject: [PATCH 2/4] make ptile/edge/corner mutable --- .../mindustry/graphics/g3d/PlanetGrid.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/core/src/mindustry/graphics/g3d/PlanetGrid.java b/core/src/mindustry/graphics/g3d/PlanetGrid.java index 3f5ee0630a..c0c7ebbe9e 100644 --- a/core/src/mindustry/graphics/g3d/PlanetGrid.java +++ b/core/src/mindustry/graphics/g3d/PlanetGrid.java @@ -221,12 +221,12 @@ public class PlanetGrid{ } public static class Ptile{ - public final int id; - public final int edgeCount; + public int id; + public int edgeCount; - public final Ptile[] tiles; - public final Corner[] corners; - public final Edge[] edges; + public Ptile[] tiles; + public Corner[] corners; + public Edge[] edges; public Vec3 v = new Vec3(); @@ -241,11 +241,11 @@ public class PlanetGrid{ } public static class Corner{ - public final int id; - public final Ptile[] tiles = new Ptile[3]; - public final Corner[] corners = new Corner[3]; - public final Edge[] edges = new Edge[3]; - public final Vec3 v = new Vec3(); + public int id; + public Ptile[] tiles = new Ptile[3]; + public Corner[] corners = new Corner[3]; + public Edge[] edges = new Edge[3]; + public Vec3 v = new Vec3(); public Corner(int id){ this.id = id; @@ -253,9 +253,9 @@ public class PlanetGrid{ } public static class Edge{ - public final int id; - public final Ptile[] tiles = new Ptile[2]; - public final Corner[] corners = new Corner[2]; + public int id; + public Ptile[] tiles = new Ptile[2]; + public Corner[] corners = new Corner[2]; public Edge(int id){ this.id = id; From 060152fc2959b4df337bfeb933e3ad0ad48820f3 Mon Sep 17 00:00:00 2001 From: DeltaNedas Date: Fri, 16 Oct 2020 23:06:46 +0100 Subject: [PATCH 3/4] make calc stuff pkg private again --- core/src/mindustry/graphics/g3d/PlanetGrid.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/mindustry/graphics/g3d/PlanetGrid.java b/core/src/mindustry/graphics/g3d/PlanetGrid.java index c0c7ebbe9e..8fb19dff56 100644 --- a/core/src/mindustry/graphics/g3d/PlanetGrid.java +++ b/core/src/mindustry/graphics/g3d/PlanetGrid.java @@ -187,36 +187,36 @@ public class PlanetGrid{ } } - public static int pos(Ptile t, Ptile n){ + static int pos(Ptile t, Ptile n){ for(int i = 0; i < t.edgeCount; i++) if(t.tiles[i] == n) return i; return -1; } - public static int pos(Ptile t, Corner c){ + static int pos(Ptile t, Corner c){ for(int i = 0; i < t.edgeCount; i++) if(t.corners[i] == c) return i; return -1; } - public static int pos(Corner c, Corner n){ + static int pos(Corner c, Corner n){ for(int i = 0; i < 3; i++) if(c.corners[i] == n) return i; return -1; } - public static int tileCount(int size){ + static int tileCount(int size){ return 10 * Mathf.pow(3, size) + 2; } - public static int cornerCount(int size){ + static int cornerCount(int size){ return 20 * Mathf.pow(3, size); } - public static int edgeCount(int size){ + static int edgeCount(int size){ return 30 * Mathf.pow(3, size); } From 0fa947bfaa4bc7dd4a0242859267ccb2b20ed7a3 Mon Sep 17 00:00:00 2001 From: DeltaNedas Date: Fri, 16 Oct 2020 23:22:39 +0100 Subject: [PATCH 4/4] make calc stuff pkg private again --- core/src/mindustry/graphics/g3d/PlanetGrid.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/graphics/g3d/PlanetGrid.java b/core/src/mindustry/graphics/g3d/PlanetGrid.java index 8fb19dff56..380f937658 100644 --- a/core/src/mindustry/graphics/g3d/PlanetGrid.java +++ b/core/src/mindustry/graphics/g3d/PlanetGrid.java @@ -163,7 +163,7 @@ public class PlanetGrid{ return grid; } - public static void addCorner(int id, PlanetGrid grid, int t1, int t2, int t3){ + static void addCorner(int id, PlanetGrid grid, int t1, int t2, int t3){ Corner c = grid.corners[id]; Ptile[] t = {grid.tiles[t1], grid.tiles[t2], grid.tiles[t3]}; c.v.set(t[0].v).add(t[1].v).add(t[2].v).nor(); @@ -173,7 +173,7 @@ public class PlanetGrid{ } } - public static void addEdge(int id, PlanetGrid grid, int t1, int t2){ + static void addEdge(int id, PlanetGrid grid, int t1, int t2){ Edge e = grid.edges[id]; Ptile[] t = {grid.tiles[t1], grid.tiles[t2]}; Corner[] c = {