mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-13 14:49:03 +00:00
Support for color in hologram. Renamed classes: fixes #72
This commit is contained in:
@@ -17,6 +17,7 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
||||
private String hologramString = "";
|
||||
private HologramMode hologramMode = HologramMode.CLEARED;
|
||||
private HologramMode lastHologramMode = HologramMode.CLEARED;
|
||||
private int hologramColor = 0;
|
||||
|
||||
/**
|
||||
* Hit points
|
||||
@@ -34,8 +35,6 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
||||
private ConsoleMode consoleMode = ConsoleMode.NORMAL;
|
||||
private ConsoleMode lastConsoleMode = ConsoleMode.NORMAL;
|
||||
|
||||
private FloppyDisk floppyDisk;
|
||||
|
||||
private User parent;
|
||||
|
||||
private int energy;
|
||||
@@ -103,6 +102,7 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
||||
json.put("holo", hologram);
|
||||
json.put("holoStr", hologramString);
|
||||
json.put("holoMode", lastHologramMode.ordinal());
|
||||
json.put("holoC", hologramColor);
|
||||
json.put("energy", energy);
|
||||
|
||||
if (parent != null) {
|
||||
@@ -236,8 +236,7 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
||||
CLEARED,
|
||||
HEX,
|
||||
STRING,
|
||||
DEC,
|
||||
COLOR
|
||||
DEC
|
||||
}
|
||||
|
||||
public enum ConsoleMode {
|
||||
@@ -270,4 +269,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
||||
public void setConsoleMode(ConsoleMode consoleMode) {
|
||||
this.consoleMode = consoleMode;
|
||||
}
|
||||
|
||||
public void setHologramColor(int hologramColor) {
|
||||
this.hologramColor = hologramColor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.json.simple.JSONObject;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ComPort extends CpuHardware {
|
||||
public class CubotComPort extends CpuHardware {
|
||||
|
||||
public static final char HWID = 0xD;
|
||||
public static final int DEFAULT_ADDRESS = 0xD;
|
||||
@@ -22,7 +22,7 @@ public class ComPort extends CpuHardware {
|
||||
private static final int FRONT_PORT_OUT = 2;
|
||||
private static final int SELF_OUT = 3;
|
||||
|
||||
public ComPort(Cubot cubot) {
|
||||
public CubotComPort(Cubot cubot) {
|
||||
this.cubot = cubot;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class ComPort extends CpuHardware {
|
||||
return json;
|
||||
}
|
||||
|
||||
public static ComPort deserialize(JSONObject json) {
|
||||
return new ComPort((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) json.get("cubot")));
|
||||
public static CubotComPort deserialize(JSONObject json) {
|
||||
return new CubotComPort((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) json.get("cubot")));
|
||||
}
|
||||
}
|
||||
@@ -71,8 +71,7 @@ public class CubotHologram extends CpuHardware {
|
||||
int b = getCpu().getRegisterSet().getRegister("B").getValue();
|
||||
int c = getCpu().getRegisterSet().getRegister("C").getValue();
|
||||
|
||||
cubot.setHologramMode(Cubot.HologramMode.COLOR);
|
||||
cubot.setHologram((c | (b << 16)) & 0x00FFFFFF); //B:C, ignore first byte
|
||||
cubot.setHologramColor((c | (b << 16))); //B:C
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.simon987.server.assembly.CpuHardware;
|
||||
import net.simon987.server.assembly.Status;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class Keyboard extends CpuHardware {
|
||||
public class CubotKeyboard extends CpuHardware {
|
||||
|
||||
public static final int DEFAULT_ADDRESS = 4;
|
||||
|
||||
@@ -19,7 +19,7 @@ public class Keyboard extends CpuHardware {
|
||||
|
||||
private Cubot cubot;
|
||||
|
||||
public Keyboard(Cubot cubot) {
|
||||
public CubotKeyboard(Cubot cubot) {
|
||||
this.cubot = cubot;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Keyboard extends CpuHardware {
|
||||
return json;
|
||||
}
|
||||
|
||||
public static Keyboard deserialize(JSONObject hwJSON) {
|
||||
return new Keyboard((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) hwJSON.get("cubot")));
|
||||
public static CubotKeyboard deserialize(JSONObject hwJSON) {
|
||||
return new CubotKeyboard((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) hwJSON.get("cubot")));
|
||||
}
|
||||
}
|
||||
@@ -50,16 +50,16 @@ public class CubotPlugin extends ServerPlugin implements GameObjectDeserializer,
|
||||
return CubotDrill.deserialize(hwJson);
|
||||
case CubotInventory.HWID:
|
||||
return CubotInventory.deserialize(hwJson);
|
||||
case Keyboard.HWID:
|
||||
return Keyboard.deserialize(hwJson);
|
||||
case CubotKeyboard.HWID:
|
||||
return CubotKeyboard.deserialize(hwJson);
|
||||
case CubotHologram.HWID:
|
||||
return CubotHologram.deserialize(hwJson);
|
||||
case CubotBattery.HWID:
|
||||
return CubotBattery.deserialize(hwJson);
|
||||
case CubotFloppyDrive.HWID:
|
||||
return CubotFloppyDrive.deserialize(hwJson);
|
||||
case ComPort.HWID:
|
||||
return ComPort.deserialize(hwJson);
|
||||
case CubotComPort.HWID:
|
||||
return CubotComPort.deserialize(hwJson);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CpuInitialisationListener implements GameEventListener {
|
||||
laserHw.setCpu(cpu);
|
||||
CubotLidar radarHw = new CubotLidar((Cubot) user.getControlledUnit());
|
||||
radarHw.setCpu(cpu);
|
||||
Keyboard keyboard = new Keyboard((Cubot) user.getControlledUnit());
|
||||
CubotKeyboard keyboard = new CubotKeyboard((Cubot) user.getControlledUnit());
|
||||
keyboard.setCpu(cpu);
|
||||
CubotDrill drillHw = new CubotDrill((Cubot) user.getControlledUnit());
|
||||
drillHw.setCpu(cpu);
|
||||
@@ -38,19 +38,19 @@ public class CpuInitialisationListener implements GameEventListener {
|
||||
batteryHw.setCpu(cpu);
|
||||
CubotFloppyDrive floppyHw = new CubotFloppyDrive((Cubot) user.getControlledUnit());
|
||||
floppyHw.setCpu(cpu);
|
||||
ComPort comPortHw = new ComPort((Cubot) user.getControlledUnit());
|
||||
CubotComPort comPortHw = new CubotComPort((Cubot) user.getControlledUnit());
|
||||
comPortHw.setCpu(cpu);
|
||||
|
||||
cpu.attachHardware(legHw, CubotLeg.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(laserHw, CubotLaser.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(radarHw, CubotLidar.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(keyboard, Keyboard.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(keyboard, CubotKeyboard.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);
|
||||
cpu.attachHardware(batteryHw, CubotBattery.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(floppyHw, CubotFloppyDrive.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(comPortHw, ComPort.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(comPortHw, CubotComPort.DEFAULT_ADDRESS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user