Entity based mapping has gotten to the renderer

This commit is contained in:
Danielv123 committed 2018-01-03 14:17:33 +01:00
1 parent 1b405b8701
commit 9ae20886b3
6 files changed
+106 -14

No files matched your search

+20 -7
View File
@@ -1,7 +1,7 @@
const needle = require("needle");
const ioClient = require("socket.io-client");
const chunkStore = require("./../../lib/chunkStore.js");
const chunkStore = require("./chunkStore.js");
const moduleConfig = require("./config"); // not to be confused with clusterio config. This config is private to this plugin.
@@ -10,7 +10,6 @@ class remoteMap {
this.config = slaveConfig;
this.messageInterface = messageInterface;
// initialize chunk database
this.chunkMap = new chunkStore(this.config.unique, 64, "./database/chunkStore/");
@@ -21,17 +20,32 @@ class remoteMap {
this.socket.emit("registerSlaveMapper", {instanceID: this.config.unique});
});
this.socket.on("getChunk", req => {
this.chunkMap.getChunk(req.x, req.y).then(chunk => {
console.log("getChunk is not supported!");
/*this.chunkMap.getChunk(req.x, req.y).then(chunk => {
chunk.requesterID = req.requesterID;
this.socket.emit("sendChunk", chunk);
});
});*/
});
this.socket.on("getEntity", req => {
if(req.requesterID && req.x && !isNaN(Number(req.x)) && req.y && !isNaN(Number(req.y))){
this.chunkMap.getEntity(req.x, req.y).then(entities => {
if(entities && entities.length > 0){
entities.forEach(entity => {
entity.requesterID = req.requesterID;
this.socket.emit("sendEntity", entity);
});
}
});
} else {
this.messageInterface("socket.getEntity triggered called with invalid parameters");
}
});
this.messageInterface("/silent-command game.print('"+moduleConfig.name+" version "+moduleConfig.version+" enabled')");
}
scriptOutput(data){
if(data){
this.messageInterface(data);
//this.messageInterface(data);
// express-transport-belt -35.5 -14.5
data = data.split(" ");
@@ -52,8 +66,7 @@ class remoteMap {
} else {
// save this entity in the database
this.chunkMap.setEntity(xPos, yPos, {name}).then(data => {
data = data[0];
this.messageInterface("Added "+name+" to data "+data.x+", "+data.y);
this.messageInterface("Added "+name+" to data "+xPos+", "+yPos);
}).catch((err)=>this.messageInterface(err));
}
}