TileMap now uses Tile instances instead of ints. No changes in the way it is stored in the database

This commit is contained in:
Simon
2018-11-15 12:08:44 -05:00
parent e50bcdeab7
commit 4be1bf2e8a
21 changed files with 268 additions and 100 deletions

View File

@@ -1,6 +1,7 @@
package net.simon987.biomassplugin;
import net.simon987.server.game.world.TileMap;
import net.simon987.server.game.world.TilePlain;
import net.simon987.server.game.world.World;
import org.bson.types.ObjectId;
@@ -21,12 +22,12 @@ public class WorldUtils {
//Count number of plain tiles. If there is less plain tiles than desired amount of blobs,
//set the desired amount of blobs to the plain tile count
int[][] tiles = world.getTileMap().getTiles();
TileMap m = world.getTileMap();
int plainCount = 0;
for (int y = 0; y < world.getWorldSize(); y++) {
for (int x = 0; x < world.getWorldSize(); x++) {
if (tiles[x][y] == TileMap.PLAIN_TILE) {
if (m.getTileIdAt(x, y) == TilePlain.ID) {
plainCount++;
}
}
@@ -39,14 +40,14 @@ public class WorldUtils {
outerLoop:
for (int i = 0; i < blobCount; i++) {
Point p = world.getTileMap().getRandomTile(TileMap.PLAIN_TILE);
Point p = m.getRandomTile(TilePlain.ID);
if (p != null) {
//Don't block worlds
int counter = 0;
while (p.x == 0 || p.y == 0 || p.x == world.getWorldSize() - 1 || p.y == world.getWorldSize() - 1 ||
world.getGameObjectsAt(p.x, p.y).size() != 0) {
p = world.getTileMap().getRandomTile(TileMap.PLAIN_TILE);
p = m.getRandomTile(TilePlain.ID);
counter++;
if (counter > 25) {