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

@@ -1,6 +1,7 @@
package net.simon987.cubotplugin;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.ControllableUnit;
import org.bson.Document;
public class CubotBattery extends CubotHardware {
@@ -19,8 +20,8 @@ public class CubotBattery extends CubotHardware {
super(cubot);
}
public CubotBattery(Document document) {
super(document);
public CubotBattery(Document document, ControllableUnit cubot) {
super(document, cubot);
}
@Override
@@ -33,6 +34,8 @@ public class CubotBattery extends CubotHardware {
} else if (a == BATTERY_GET_MAX_CAPACITY) {
getCpu().getRegisterSet().getRegister("B").setValue(cubot.getMaxEnergy());
//TODO: Remove debug action
} else if (a == 0xFFFF) {
cubot.setEnergy(cubot.getMaxEnergy());
}

View File

@@ -1,6 +1,7 @@
package net.simon987.cubotplugin;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.ControllableUnit;
import net.simon987.server.game.objects.GameObject;
import net.simon987.server.game.objects.Programmable;
import org.bson.Document;
@@ -23,8 +24,8 @@ public class CubotComPort extends CubotHardware {
super(cubot);
}
public CubotComPort(Document document) {
super(document);
public CubotComPort(Document document, ControllableUnit cubot) {
super(document, cubot);
}
private static final int MESSAGE_LENGTH = 8;
@@ -117,8 +118,6 @@ public class CubotComPort extends CubotHardware {
getCpu().getRegisterSet().getRegister("B").setValue(0); //Failed
}
}
@Override

View File

@@ -1,6 +1,7 @@
package net.simon987.cubotplugin;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.ControllableUnit;
import org.bson.Document;
public class CubotCore extends CubotHardware {
@@ -19,8 +20,8 @@ public class CubotCore extends CubotHardware {
super(cubot);
}
public CubotCore(Document document) {
super(document);
public CubotCore(Document document, ControllableUnit cubot) {
super(document, cubot);
}
@Override

View File

@@ -2,6 +2,7 @@ package net.simon987.cubotplugin;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.Action;
import net.simon987.server.game.objects.ControllableUnit;
import net.simon987.server.game.world.TileMap;
import org.bson.Document;
@@ -21,8 +22,8 @@ public class CubotDrill extends CubotHardware {
super(cubot);
}
public CubotDrill(Document document) {
super(document);
public CubotDrill(Document document, ControllableUnit cubot) {
super(document, cubot);
}
@Override

View File

@@ -1,6 +1,7 @@
package net.simon987.cubotplugin;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.ControllableUnit;
import org.bson.Document;
public class CubotFloppyDrive extends CubotHardware {
@@ -24,8 +25,8 @@ public class CubotFloppyDrive extends CubotHardware {
floppyDisk = new FloppyDisk();
}
public CubotFloppyDrive(Document document) {
super(document);
public CubotFloppyDrive(Document document, ControllableUnit cubot) {
super(document, cubot);
if (document.containsKey("floppy")) {
floppyDisk = new FloppyDisk((Document) document.get("floppy"));

View File

@@ -1,15 +1,15 @@
package net.simon987.cubotplugin;
import net.simon987.server.GameServer;
import net.simon987.server.assembly.CpuHardware;
import net.simon987.server.game.objects.ControllableUnit;
import org.bson.Document;
public abstract class CubotHardware extends CpuHardware {
protected Cubot cubot;
public CubotHardware(Document document) {
this.cubot = (Cubot) GameServer.INSTANCE.getGameUniverse().getObject((long) document.get("cubot"));
public CubotHardware(Document document, ControllableUnit cubot) {
this.cubot = (Cubot) cubot;
}
public CubotHardware(Cubot cubot) {
@@ -21,7 +21,6 @@ public abstract class CubotHardware extends CpuHardware {
Document document = new Document();
document.put("type", getClass().getCanonicalName());
document.put("cubot", cubot.getObjectId());
return document;
}
}

View File

@@ -1,6 +1,7 @@
package net.simon987.cubotplugin;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.ControllableUnit;
import org.bson.Document;
public class CubotHologram extends CubotHardware {
@@ -25,8 +26,8 @@ public class CubotHologram extends CubotHardware {
super(cubot);
}
public CubotHologram(Document document) {
super(document);
public CubotHologram(Document document, ControllableUnit cubot) {
super(document, cubot);
}
@Override

View File

@@ -2,6 +2,7 @@ package net.simon987.cubotplugin;
import net.simon987.server.GameServer;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.ControllableUnit;
import org.bson.Document;
public class CubotInventory extends CubotHardware {
@@ -20,8 +21,8 @@ public class CubotInventory extends CubotHardware {
super(cubot);
}
public CubotInventory(Document document) {
super(document);
public CubotInventory(Document document, ControllableUnit cubot) {
super(document, cubot);
}
@Override

View File

@@ -1,6 +1,7 @@
package net.simon987.cubotplugin;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.ControllableUnit;
import org.bson.Document;
public class CubotKeyboard extends CubotHardware {
@@ -19,8 +20,8 @@ public class CubotKeyboard extends CubotHardware {
super(cubot);
}
public CubotKeyboard(Document document) {
super(document);
public CubotKeyboard(Document document, ControllableUnit cubot) {
super(document, cubot);
}
@Override

View File

@@ -1,10 +1,7 @@
package net.simon987.cubotplugin;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.Action;
import net.simon987.server.game.objects.Attackable;
import net.simon987.server.game.objects.GameObject;
import net.simon987.server.game.objects.InventoryHolder;
import net.simon987.server.game.objects.*;
import org.bson.Document;
import java.awt.*;
@@ -29,8 +26,8 @@ public class CubotLaser extends CubotHardware {
super(cubot);
}
public CubotLaser(Document document) {
super(document);
public CubotLaser(Document document, ControllableUnit cubot) {
super(document, cubot);
}
@Override

View File

@@ -2,6 +2,7 @@ package net.simon987.cubotplugin;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.Action;
import net.simon987.server.game.objects.ControllableUnit;
import net.simon987.server.game.objects.Direction;
import org.bson.Document;
@@ -21,8 +22,8 @@ public class CubotLeg extends CubotHardware {
super(cubot);
}
public CubotLeg(Document document) {
super(document);
public CubotLeg(Document document, ControllableUnit cubot) {
super(document, cubot);
}
@Override

View File

@@ -2,6 +2,7 @@ package net.simon987.cubotplugin;
import net.simon987.server.assembly.Memory;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.ControllableUnit;
import net.simon987.server.game.pathfinding.Node;
import net.simon987.server.game.pathfinding.Pathfinder;
import net.simon987.server.logging.LogManager;
@@ -30,8 +31,8 @@ public class CubotLidar extends CubotHardware {
super(cubot);
}
public CubotLidar(Document document) {
super(document);
public CubotLidar(Document document, ControllableUnit cubot) {
super(document, cubot);
}
@Override

View File

@@ -2,6 +2,7 @@ package net.simon987.cubotplugin;
import net.simon987.server.GameServer;
import net.simon987.server.assembly.Status;
import net.simon987.server.game.objects.ControllableUnit;
import org.bson.Document;
public class CubotShield extends CubotHardware {
@@ -19,8 +20,8 @@ public class CubotShield extends CubotHardware {
super(cubot);
}
public CubotShield(Document document) {
super(document);
public CubotShield(Document document, ControllableUnit cubot) {
super(document, cubot);
}
@Override

View File

@@ -29,7 +29,7 @@ public class FloppyDisk implements MongoSerializable {
}
public FloppyDisk(Document document) {
this.rwHeadTrack = (int) document.get("rwHeadTrack");
this.rwHeadTrack = document.getInteger("rwHeadTrack");
this.memory = new Memory((Document) document.get("memory"));
}