Move hologram-related fields to proper class. Breaks existing database saves!

This commit is contained in:
Simon
2018-11-27 14:38:33 -05:00
parent b361583252
commit 54ed05b86c
5 changed files with 132 additions and 98 deletions

View File

@@ -2,11 +2,13 @@ package net.simon987.server.assembly;
import net.simon987.server.game.objects.ControllableUnit;
import net.simon987.server.io.JSONSerialisable;
import net.simon987.server.io.MongoSerializable;
import org.bson.Document;
import org.json.simple.JSONObject;
public abstract class HardwareModule implements MongoSerializable {
public abstract class HardwareModule implements MongoSerializable, JSONSerialisable {
private CPU cpu;
@@ -35,6 +37,25 @@ public abstract class HardwareModule implements MongoSerializable {
@Override
public String toString() {
return String.format("{%s}", getClass().getSimpleName());
JSONObject hwJson = jsonSerialise();
return String.format("{%s: {%s}}", getClass().getSimpleName(), hwJson == null ? "" : hwJson);
}
public void reset() {
}
public void update() {
}
@Override
public JSONObject jsonSerialise() {
return null;
}
@Override
public JSONObject debugJsonSerialise() {
return null;
}
}

View File

@@ -1023,7 +1023,8 @@ var Cubot = (function (_super) {
this.makeLaserAttack();
}
this.updateDirection();
this.updateHologram(json.holoMode, json.holoC, json.holo, json.holoStr);
var holoHw = json["net.simon987.cubotplugin.CubotHologram"];
this.updateHologram(holoHw.mode, holoHw.color, holoHw.value, holoHw.string);
this.setShield(this.shield > 0);
};
Cubot.prototype.updateHologram = function (holoMode, holoColor, holoValue, holoStr) {
@@ -1579,7 +1580,6 @@ var FluidTile = (function (_super) {
}(Tile));
var MagneticTile = (function (_super) {
__extends(MagneticTile, _super);
function MagneticTile(x, y) {
var _this = _super.call(this, x, y, config.magneticSprite, 0) || this;
_this.baseTint = 0xFFFFFF;
@@ -1588,7 +1588,6 @@ var MagneticTile = (function (_super) {
_this.tileType = "Magnetic tile";
return _this;
}
MagneticTile.prototype.onHover = function () {
mar.game.add.tween(this).to({isoZ: this.baseZ + 30}, 200, Phaser.Easing.Quadratic.InOut, true);
mar.tileIndicator.tileX = this.tileX;

View File

@@ -326,7 +326,8 @@ class Cubot extends GameObject {
}
this.updateDirection();
this.updateHologram(json.holoMode, json.holoC, json.holo, json.holoStr);
let holoHw = json["net.simon987.cubotplugin.CubotHologram"];
this.updateHologram(holoHw.mode, holoHw.color, holoHw.value, holoHw.string);
//Update shield
this.setShield(this.shield > 0)