Cubot object id is no longer stored inside every CpuHardware in the database. Renamed some fields in the database to make them more readable

This commit is contained in:
simon
2018-05-12 16:16:24 -04:00
parent 4cd58c86a5
commit 3368268924
27 changed files with 83 additions and 74 deletions

View File

@@ -44,7 +44,7 @@ public class ElectricBox extends GameObject implements Updatable, Attackable {
public ElectricBox(Document document) {
super(document);
hp = (int) document.get("hp");
hp = document.getInteger("hp");
}
/**

View File

@@ -53,11 +53,7 @@ public class Factory extends GameObject implements Updatable {
public Factory(Document document) {
super(document);
setObjectId((long) document.get("i"));
setX((int) document.get("x"));
setY((int) document.get("y"));
tmpNpcArray = ((ArrayList) document.get("tmpNpcArray")).toArray();
tmpNpcArray = ((ArrayList) document.get("npcs")).toArray();
}
@Override
@@ -78,13 +74,12 @@ public class Factory extends GameObject implements Updatable {
for (Object id : tmpNpcArray) {
NonPlayerCharacter npc = (NonPlayerCharacter) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) id);
NonPlayerCharacter npc = (NonPlayerCharacter) GameServer.INSTANCE.getGameUniverse().getObject((long) id);
if (npc != null) {
npc.setFactory(this);
npcs.add(npc);
}
}
tmpNpcArray = null;
@@ -139,7 +134,7 @@ public class Factory extends GameObject implements Updatable {
tmpNpcArray.add(npc.getObjectId());
}
dbObject.put("n", tmpNpcArray);
dbObject.put("npcs", tmpNpcArray);
return dbObject;
}

View File

@@ -24,6 +24,8 @@ public class HarvesterNPC extends NonPlayerCharacter {
public HarvesterNPC(Document document) {
super(document);
setTask(new HarvestTask());
setDirection(Direction.getDirection(document.getInteger("direction")));
}

View File

@@ -24,8 +24,8 @@ public class RadioReceiverHardware extends CpuHardware {
this.cubot = cubot;
}
public RadioReceiverHardware(Document document) {
super(document);
public RadioReceiverHardware(Document document, ControllableUnit unit) {
super(document, unit);
this.cubot = (ControllableUnit) GameServer.INSTANCE.getGameUniverse().getObject((long) document.get("cubot"));
}

View File

@@ -145,7 +145,7 @@ public class VaultDoor extends GameObject implements Programmable, Enterable, Up
dbObject.put("homeX", getHomeX());
dbObject.put("homeY", getHomeY());
dbObject.put("pw", new String(password));
dbObject.put("password", new String(password));
return dbObject;
}