I am starting out with lance-gg and am building a game in which a new game map is generated every few minutes. The client game engine needs to receive the generated map. Currently I am registering the map as a serializable object and adding a new instance to the game world when the server starts.
class Map extends serialize.DynamicObject {
constructor(id, width, height) {
super(id);
this.class = Map;
this.width = width;
this.height = height;
this.netScheme = {
tiles: { type: "CLASSINSTANCE" },
};
}
randomTiles() {
const tiles = [];
_.forEach(_.range(this.width), (x) => {
tiles[x] = [];
_.forEach(_.range(this.height), (y) => {
tiles[x][y] = _.random(0, 1);
});
});
return tiles;
}
}
The map is a double array of integers and might be quite large so I'd like to avoid implementing it as part of a netscheme (which I dont think I'm doing correctly here anyway) as it doesn't need to be updated very often. I would also like to keep a reference to it in the game world to keep it separate from objects that actually change position.
What is the best way to do this?