Started working on Vault worlds generation

This commit is contained in:
simon
2018-02-26 10:04:06 -05:00
parent 8c6e580ea9
commit 62f1403cb3
8 changed files with 152 additions and 34 deletions

View File

@@ -82,8 +82,8 @@ public class GameUniverse {
public World getWorld(int x, int y, boolean createNew, String dimension) {
// Wrapping coordinates around cyclically
x %= maxWidth+1;
y %= maxWidth+1;
x %= maxWidth;
y %= maxWidth;
// Looks for a previously loaded world
World world = getLoadedWorld(x, y, dimension);
@@ -113,8 +113,8 @@ public class GameUniverse {
World getLoadedWorld(int x, int y, String dimension) {
// Wrapping coordinates around cyclically
x %= maxWidth+1;
y %= maxWidth+1;
x %= maxWidth;
y %= maxWidth;
return worlds.get(World.idFromCoordinates(x, y, dimension));
}

View File

@@ -31,7 +31,7 @@ public class World implements MongoSerialisable {
private TileMap tileMap;
private static String dimension = "w-";
private String dimension;
private ConcurrentHashMap<Long, GameObject> gameObjects = new ConcurrentHashMap<>(8);
@@ -40,10 +40,11 @@ public class World implements MongoSerialisable {
*/
private int updatable = 0;
public World(int x, int y, TileMap tileMap) {
public World(int x, int y, TileMap tileMap, String dimension) {
this.x = x;
this.y = y;
this.tileMap = tileMap;
this.dimension = dimension;
this.worldSize = tileMap.getWidth();
}
@@ -174,6 +175,7 @@ public class World implements MongoSerialisable {
dbObject.put("_id", getId());
dbObject.put("dimension", getDimension());
dbObject.put("objects", objects);
dbObject.put("terrain", tileMap.mongoSerialise());
@@ -210,6 +212,7 @@ public class World implements MongoSerialisable {
World world = new World((int) dbObject.get("size"));
world.x = (int) dbObject.get("x");
world.y = (int) dbObject.get("y");
world.dimension = (String) dbObject.get("dimension");
world.updatable = (int) dbObject.get("updatable");
world.tileMap = TileMap.deserialize((BasicDBObject) dbObject.get("terrain"), world.getWorldSize());

View File

@@ -87,7 +87,7 @@ public class WorldGenerator {
*/
private static World generateEmptyWorld(int locX, int locY) {
return new World(locX, locY, new TileMap(DEFAULT_WORLD_SIZE, DEFAULT_WORLD_SIZE));
return new World(locX, locY, new TileMap(DEFAULT_WORLD_SIZE, DEFAULT_WORLD_SIZE), "w-");
}
/**