From c721ce97e1df4198d5a2cae32c3bf9d23e8dc0af Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 25 Feb 2018 14:15:11 -0500 Subject: [PATCH] Added support for multiple dimensions --- mar/GameClient.ts | 6 ++++-- mar/MarGame.ts | 2 +- mar/app.js | 31 +++++++++++++++++-------------- mar/mar.ts | 24 +++++++++++++----------- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/mar/GameClient.ts b/mar/GameClient.ts index 41fe200..6638bfb 100644 --- a/mar/GameClient.ts +++ b/mar/GameClient.ts @@ -104,6 +104,7 @@ class UserInfoListener implements MessageListener { mar.client.worldX = message.worldX; mar.client.worldY = message.worldY; + mar.client.dimension = message.dimension; //Maximum Universe width mar.client.maxWidth = message.maxWidth; @@ -268,6 +269,7 @@ class GameClient { public worldX: number; public worldY: number; + public dimension: string; public consoleScreen: PlainTextConsole; @@ -292,7 +294,7 @@ class GameClient { console.log("[MAR] Requesting terrain for world (" + this.worldX + ", " + this.worldY + ")"); } - this.socket.send(JSON.stringify({t: "terrain", x: this.worldX, y: this.worldY})); + this.socket.send(JSON.stringify({t: "terrain", x: this.worldX, y: this.worldY, dimension: this.dimension})); this.requestObjects(); } @@ -349,7 +351,7 @@ class GameClient { console.log("[MAR] Requesting game objects"); } - this.socket.send(JSON.stringify({t: "object", x: this.worldX, y: this.worldY})); + this.socket.send(JSON.stringify({t: "object", x: this.worldX, y: this.worldY, dimension: this.dimension})); } public sendDebugCommand(json): void { diff --git a/mar/MarGame.ts b/mar/MarGame.ts index 1f47ed8..224bdb2 100644 --- a/mar/MarGame.ts +++ b/mar/MarGame.ts @@ -315,7 +315,7 @@ class WorldIndicator extends DebugMessage { if (mar.world != undefined) { - return "World: (" + Number(mar.client.worldX).toString(16).toUpperCase() + ", " + + return "World: " + mar.client.dimension + "(" + Number(mar.client.worldX).toString(16).toUpperCase() + ", " + Number(mar.client.worldY).toString(16).toUpperCase() + ")"; } else { diff --git a/mar/app.js b/mar/app.js index 6bf67c0..d66e311 100644 --- a/mar/app.js +++ b/mar/app.js @@ -255,7 +255,7 @@ var WorldIndicator = /** @class */ (function (_super) { } WorldIndicator.prototype.getMessage = function () { if (mar.world != undefined) { - return "World: (" + Number(mar.client.worldX).toString(16).toUpperCase() + ", " + + return "World: " + mar.client.dimension + "(" + Number(mar.client.worldX).toString(16).toUpperCase() + ", " + Number(mar.client.worldY).toString(16).toUpperCase() + ")"; } else { @@ -298,7 +298,7 @@ var config = { font: "fixedsys" }; }, - kbBufferX: 225, + kbBufferX: 350, kbBufferY: 20, arrowTextStyle: { fontSize: 32, @@ -368,31 +368,33 @@ var Debug = /** @class */ (function () { worldX: mar.client.worldX, worldY: mar.client.worldY }); mar.client.requestTerrain(); //Reload terrain }; - Debug.createWorld = function (x, y) { - mar.client.sendDebugCommand({ t: "debug", command: "createWorld", worldX: x, worldY: y }); + Debug.createWorld = function (x, y, dimension) { + mar.client.sendDebugCommand({ t: "debug", command: "createWorld", worldX: x, worldY: y, dimension: dimension }); mar.client.requestTerrain(); //Reload terrain }; - Debug.createWorldHex = function (x, y) { - mar.client.sendDebugCommand({ t: "debug", command: "createWorld", worldX: parseInt(x, 16), worldY: parseInt(y, 16) }); - mar.client.requestTerrain(); //Reload terrain + Debug.createWorldHex = function (x, y, dimension) { + mar.client.sendDebugCommand({ t: "debug", command: "createWorld", + worldX: parseInt(x, 16), worldY: parseInt(y, 16), dimension: dimension }); }; - Debug.goTo = function (worldX, worldY) { + Debug.goTo = function (worldX, worldY, dimension) { mar.client.worldX = worldX; mar.client.worldY = worldY; + mar.client.dimension = dimension; mar.client.requestTerrain(); //Reload terrain }; - Debug.goToHex = function (worldX, worldY) { + Debug.goToHex = function (worldX, worldY, dimension) { mar.client.worldX = parseInt(worldX, 16); mar.client.worldY = parseInt(worldY, 16); + mar.client.dimension = dimension; mar.client.requestTerrain(); }; Debug.killAll = function (x, y) { mar.client.sendDebugCommand({ t: "debug", command: "killAll", x: x, y: y, - worldX: mar.client.worldX, worldY: mar.client.worldY }); + worldX: mar.client.worldX, worldY: mar.client.worldY, dimension: mar.client.dimension }); }; Debug.objInfo = function (x, y) { mar.client.sendDebugCommand({ t: "debug", command: "objInfo", x: x, y: y, - worldX: mar.client.worldX, worldY: mar.client.worldY }); + worldX: mar.client.worldX, worldY: mar.client.worldY, dimension: mar.client.dimension }); }; Debug.userInfo = function (username) { mar.client.sendDebugCommand({ t: "debug", command: "userInfo", username: username }); @@ -403,7 +405,7 @@ var Debug = /** @class */ (function () { }; Debug.spawnObj = function (data) { mar.client.sendDebugCommand({ t: "debug", command: "spawnObj", data: data, - worldX: mar.client.worldX, worldY: mar.client.worldY }); + worldX: mar.client.worldX, worldY: mar.client.worldY, dimension: mar.client.dimension }); }; return Debug; }()); @@ -493,6 +495,7 @@ var UserInfoListener = /** @class */ (function () { } mar.client.worldX = message.worldX; mar.client.worldY = message.worldY; + mar.client.dimension = message.dimension; //Maximum Universe width mar.client.maxWidth = message.maxWidth; mar.client.requestTerrain(); @@ -627,7 +630,7 @@ var GameClient = /** @class */ (function () { if (DEBUG) { console.log("[MAR] Requesting terrain for world (" + this.worldX + ", " + this.worldY + ")"); } - this.socket.send(JSON.stringify({ t: "terrain", x: this.worldX, y: this.worldY })); + this.socket.send(JSON.stringify({ t: "terrain", x: this.worldX, y: this.worldY, dimension: this.dimension })); this.requestObjects(); }; GameClient.prototype.uploadCode = function (code) { @@ -668,7 +671,7 @@ var GameClient = /** @class */ (function () { if (DEBUG) { console.log("[MAR] Requesting game objects"); } - this.socket.send(JSON.stringify({ t: "object", x: this.worldX, y: this.worldY })); + this.socket.send(JSON.stringify({ t: "object", x: this.worldX, y: this.worldY, dimension: this.dimension })); }; GameClient.prototype.sendDebugCommand = function (json) { this.socket.send(JSON.stringify(json)); diff --git a/mar/mar.ts b/mar/mar.ts index 55a4de8..29f5b4e 100644 --- a/mar/mar.ts +++ b/mar/mar.ts @@ -35,7 +35,7 @@ let config = { font: "fixedsys" } }, - kbBufferX: 225, ///Position of the keyboard buffer fill on screen + kbBufferX: 350, ///Position of the keyboard buffer fill on screen kbBufferY: 20, arrowTextStyle: { fontSize: 32, @@ -117,36 +117,38 @@ class Debug { mar.client.requestTerrain(); //Reload terrain } - public static createWorld(x, y) { - mar.client.sendDebugCommand({t:"debug", command: "createWorld", worldX: x, worldY: y}); + public static createWorld(x, y, dimension) { + mar.client.sendDebugCommand({t:"debug", command: "createWorld", worldX: x, worldY: y, dimension:dimension}); mar.client.requestTerrain(); //Reload terrain } - public static createWorldHex(x, y) { - mar.client.sendDebugCommand({t:"debug", command: "createWorld", worldX: parseInt(x, 16), worldY: parseInt(y, 16)}); - mar.client.requestTerrain(); //Reload terrain + public static createWorldHex(x, y, dimension) { + mar.client.sendDebugCommand({t:"debug", command: "createWorld", + worldX: parseInt(x, 16), worldY: parseInt(y, 16), dimension:dimension}); } - public static goTo(worldX, worldY) { + public static goTo(worldX, worldY, dimension) { mar.client.worldX = worldX; mar.client.worldY = worldY; + mar.client.dimension = dimension; mar.client.requestTerrain(); //Reload terrain } - public static goToHex(worldX, worldY) { + public static goToHex(worldX, worldY, dimension) { mar.client.worldX = parseInt(worldX, 16); mar.client.worldY = parseInt(worldY, 16); + mar.client.dimension = dimension; mar.client.requestTerrain(); } public static killAll(x, y) { mar.client.sendDebugCommand({t:"debug", command: "killAll", x: x, y: y, - worldX: mar.client.worldX, worldY: mar.client.worldY}); + worldX: mar.client.worldX, worldY: mar.client.worldY, dimension: mar.client.dimension}); } public static objInfo(x, y) { mar.client.sendDebugCommand({t:"debug", command: "objInfo", x: x, y: y, - worldX: mar.client.worldX, worldY: mar.client.worldY}); + worldX: mar.client.worldX, worldY: mar.client.worldY, dimension: mar.client.dimension}); } public static userInfo(username) { @@ -160,7 +162,7 @@ class Debug { public static spawnObj(data) { mar.client.sendDebugCommand({t:"debug", command: "spawnObj", data: data, - worldX: mar.client.worldX, worldY: mar.client.worldY}); + worldX: mar.client.worldX, worldY: mar.client.worldY, dimension: mar.client.dimension}); } }