mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-13 22:59:02 +00:00
Started working on Vault worlds generation
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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-");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user