diff --git a/Plugin Cubot/src/net/simon987/cubotplugin/Cubot.java b/Plugin Cubot/src/net/simon987/cubotplugin/Cubot.java index 9865d44..116f6fa 100644 --- a/Plugin Cubot/src/net/simon987/cubotplugin/Cubot.java +++ b/Plugin Cubot/src/net/simon987/cubotplugin/Cubot.java @@ -1,6 +1,9 @@ package net.simon987.cubotplugin; -import net.simon987.server.game.*; +import net.simon987.server.game.ControllableUnit; +import net.simon987.server.game.Direction; +import net.simon987.server.game.GameObject; +import net.simon987.server.game.Updatable; import net.simon987.server.user.User; import org.json.simple.JSONObject; @@ -11,7 +14,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit { private static final char MAP_INFO = 0x0080; public static final int ID = 1; - private EffectType currentEmote = null; + private char hologram = 0; + private char lastHologram = 0; /** * Hit points @@ -45,11 +49,6 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit { } } - if (currentEmote != null) { - // getWorld().getQueuedGameEffects().add(new GameEffect(currentEmote, getX(), getY())); - currentEmote = null; - } - /* * CurrentAction is set during the code execution and this function is called right after * If no action as been set, the action sent to the client is the action in currentAction that @@ -57,6 +56,10 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit { */ lastAction = currentAction; currentAction = CubotAction.IDLE; + + //Same principle for hologram + lastHologram = hologram; + hologram = 0; } @Override @@ -70,6 +73,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit { json.put("heldItem", heldItem); json.put("hp", hp); json.put("action", lastAction.ordinal()); + json.put("holo", (int) lastHologram); + if (parent != null) { json.put("parent", parent.getUsername()); //Only used client-side for now } @@ -128,4 +133,12 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit { public CubotAction getAction() { return lastAction; } + + public void setHologram(char hologram) { + this.hologram = hologram; + } + + public char getHologram() { + return lastHologram; + } } diff --git a/Plugin Cubot/src/net/simon987/cubotplugin/CubotDrill.java b/Plugin Cubot/src/net/simon987/cubotplugin/CubotDrill.java index 1e0e3a3..beaa338 100644 --- a/Plugin Cubot/src/net/simon987/cubotplugin/CubotDrill.java +++ b/Plugin Cubot/src/net/simon987/cubotplugin/CubotDrill.java @@ -40,7 +40,7 @@ public class CubotDrill extends CpuHardware { } else if (a == GATHER_SLOW || a == GATHER_FAST) { - if (cubot.getAction() != CubotAction.IDLE) { + if (cubot.getAction() == CubotAction.IDLE) { int tile = cubot.getWorld().getTileMap().getTileAt(cubot.getX(), cubot.getY()); if (tile == TileMap.IRON_TILE) { diff --git a/Plugin Cubot/src/net/simon987/cubotplugin/CubotHologram.java b/Plugin Cubot/src/net/simon987/cubotplugin/CubotHologram.java new file mode 100644 index 0000000..d5172c4 --- /dev/null +++ b/Plugin Cubot/src/net/simon987/cubotplugin/CubotHologram.java @@ -0,0 +1,49 @@ +package net.simon987.cubotplugin; + +import net.simon987.server.GameServer; +import net.simon987.server.assembly.CpuHardware; +import net.simon987.server.assembly.Status; +import org.json.simple.JSONObject; + +public class CubotHologram extends CpuHardware { + + + /** + * Hardware ID (Should be unique) + */ + static final char HWID = 0x0009; + + public static final int DEFAULT_ADDRESS = 9; + + private Cubot cubot; + + public CubotHologram(Cubot cubot) { + this.cubot = cubot; + } + + @Override + public void handleInterrupt(Status status) { + + char a = getCpu().getRegisterSet().getRegister("A").getValue(); + cubot.setHologram(a); + + } + + @Override + public char getId() { + return HWID; + } + + public static CubotHologram deserialize(JSONObject hwJSON) { + return new CubotHologram((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) hwJSON.get("cubot"))); + } + + @Override + public JSONObject serialise() { + JSONObject json = new JSONObject(); + json.put("hwid", (int) HWID); + json.put("cubot", cubot.getObjectId()); + + return json; + } +} diff --git a/Plugin Cubot/src/net/simon987/cubotplugin/CubotLidar.java b/Plugin Cubot/src/net/simon987/cubotplugin/CubotLidar.java index 340c970..c9512b5 100644 --- a/Plugin Cubot/src/net/simon987/cubotplugin/CubotLidar.java +++ b/Plugin Cubot/src/net/simon987/cubotplugin/CubotLidar.java @@ -26,6 +26,7 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable { private static final int GET_POS = 1; private static final int GET_PATH = 2; private static final int GET_MAP = 3; + private static final int GET_WORLD_POS = 4; private static final int MEMORY_MAP_START = 0x0100; private static final int MEMORY_PATH_START = 0x0000; @@ -120,6 +121,12 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable { getCpu().getMemory().set(i++, mapInfo[x][y]); } } + break; + case GET_WORLD_POS: + getCpu().getRegisterSet().getRegister("X").setValue(cubot.getWorld().getX()); + getCpu().getRegisterSet().getRegister("Y").setValue(cubot.getWorld().getY()); + break; + } diff --git a/Plugin Cubot/src/net/simon987/cubotplugin/CubotPlugin.java b/Plugin Cubot/src/net/simon987/cubotplugin/CubotPlugin.java index 60677f5..31cc603 100644 --- a/Plugin Cubot/src/net/simon987/cubotplugin/CubotPlugin.java +++ b/Plugin Cubot/src/net/simon987/cubotplugin/CubotPlugin.java @@ -51,6 +51,8 @@ public class CubotPlugin extends ServerPlugin implements GameObjectDeserializer, return CubotInventory.deserialize(hwJson); case Keyboard.HWID: return Keyboard.deserialize(hwJson); + case CubotHologram.HWID: + return CubotHologram.deserialize(hwJson); } return null; diff --git a/Plugin Cubot/src/net/simon987/cubotplugin/event/CpuInitialisationListener.java b/Plugin Cubot/src/net/simon987/cubotplugin/event/CpuInitialisationListener.java index bbd78c2..7c962f8 100644 --- a/Plugin Cubot/src/net/simon987/cubotplugin/event/CpuInitialisationListener.java +++ b/Plugin Cubot/src/net/simon987/cubotplugin/event/CpuInitialisationListener.java @@ -33,6 +33,8 @@ public class CpuInitialisationListener implements GameEventListener { drillHw.setCpu(cpu); CubotInventory invHw = new CubotInventory((Cubot) user.getControlledUnit()); invHw.setCpu(cpu); + CubotHologram emoteHw = new CubotHologram((Cubot) user.getControlledUnit()); + emoteHw.setCpu(cpu); cpu.attachHardware(legHw, CubotLeg.DEFAULT_ADDRESS); cpu.attachHardware(laserHw, CubotLaser.DEFAULT_ADDRESS); @@ -40,5 +42,7 @@ public class CpuInitialisationListener implements GameEventListener { cpu.attachHardware(keyboard, Keyboard.DEFAULT_ADDRESS); cpu.attachHardware(drillHw, CubotDrill.DEFAULT_ADDRESS); cpu.attachHardware(invHw, CubotInventory.DEFAULT_ADDRESS); + cpu.attachHardware(invHw, CubotInventory.DEFAULT_ADDRESS); + cpu.attachHardware(emoteHw, CubotHologram.DEFAULT_ADDRESS); } } diff --git a/Server/src/net/simon987/server/Main.java b/Server/src/net/simon987/server/Main.java index d877a68..794b51f 100644 --- a/Server/src/net/simon987/server/Main.java +++ b/Server/src/net/simon987/server/Main.java @@ -11,55 +11,6 @@ public class Main { public static void main(String[] args){ - //TODO: Docs - /* - * - Intel 8086 p.14 design - * - Memory: Storage organisation: From a storage pov, 8086 memory spaces are - * organised as identical arrays of 16-bit words - * - Microprocessor - * - Instruction set - * - - */ - //TODO: Random number generator - //TODO: Clock hardware - //TODO: Floppy drive hardware (and item?) - //TODO: LEA instruction - //TODO: NOT instruction - //TODO: Battery Hardware - - //--------------------------------- - - //TODO: favicon - //TODO: Email verification - //TODO: Real account page - // Change/reset password - //TODO: Object information Window (Hover, click ?) - //TODO: Inventory indicator (Multiple items) - //TODO: Software Interrupts (PIC): Interupt flag? - /* - * - INT/INTO instruction - * - IRET instruction - */ - //TODO: XCHG instruction - //TODO: SAL/SAR instruction - //TODO: ROL/ROR/RCL/RCR instruction - //TODO: LOOP/LOOPE/LOOPX/LOOPNE/LOOPNZ ? - //TODO: World goto (form) - //TODO: Save backup (keep X saves, Zip em) - //TODO: Log backup (keep X backups, Zip em) - //TODO: More tests - //TODO: Handle client disconnects - //TODO: Cache objects requests? - //TODO: Ability to toggle debug stuff - //TODO: Data segment, DB, DW, DD, DQ - //TODO: Set client animation speed relative to TICK_LENGTH - //TODO: Withdraw animation / action - //TODO: Prevent World creation out of bounds, warp around universe - //TODO: Multiple Biomass style (and yield, rarity) - //TODO: Clean sprites - //TODO: Auto-resize - - LogManager.initialize(); ServerConfiguration config = new ServerConfiguration(new File("config.properties")); diff --git a/plugins/Cubot.jar b/plugins/Cubot.jar index b9c2743..b6ea076 100644 Binary files a/plugins/Cubot.jar and b/plugins/Cubot.jar differ