Improved World update performance. Decreased save file size. Added Harvester NPC #19.

This commit is contained in:
simon
2017-12-16 15:40:03 -05:00
parent cd41db9e58
commit 3548928218
20 changed files with 102 additions and 37 deletions

View File

@@ -77,8 +77,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
@Override
public JSONObject serialise() {
JSONObject json = new JSONObject();
json.put("id", getObjectId());
json.put("type", ID);
json.put("i", getObjectId());
json.put("t", ID);
json.put("x", getX());
json.put("y", getY());
json.put("direction", getDirection().ordinal());
@@ -98,7 +98,7 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
public static Cubot deserialize(JSONObject json) {
Cubot cubot = new Cubot();
cubot.setObjectId((int) (long) json.get("id"));
cubot.setObjectId((int) (long) json.get("i"));
cubot.setX((int) (long) json.get("x"));
cubot.setY((int) (long) json.get("y"));
cubot.hp = (int) (long) json.get("hp");

View File

@@ -25,7 +25,7 @@ public class CubotPlugin extends ServerPlugin implements GameObjectDeserializer,
@Override
public GameObject deserializeObject(JSONObject object) {
int objType = (int) (long) object.get("type");
int objType = (int) (long) object.get("t");
if (objType == Cubot.ID) {

View File

@@ -29,6 +29,7 @@ public class UserCreationListener implements GameEventListener {
GameServer.INSTANCE.getConfig().getInt("new_user_worldX"),
GameServer.INSTANCE.getConfig().getInt("new_user_worldY")));
cubot.getWorld().getGameObjects().add(cubot);
cubot.getWorld().incUpdatable();
cubot.setObjectId(GameServer.INSTANCE.getGameUniverse().getNextObjectId());