fix: toJSON

This commit is contained in:
cha0s 2021-01-13 02:33:21 -06:00
parent e00ade960d
commit c4e798a2a5
3 changed files with 18 additions and 1 deletions

View File

@ -208,6 +208,15 @@ export default (latus) => class EntityList extends decorate(JsonResource) {
}
}
toJSON() {
const json = [];
for (let i = 0; i < this.#flatEntities.length; i++) {
const entity = this.#flatEntities[i];
json.push(entity.mergeDiff(entity.toJSON()));
}
return json;
}
toNetwork(informed) {
const {areaToInform} = informed;
const visibleEntities = this.visibleEntities(areaToInform);

View File

@ -240,6 +240,14 @@ export default (latus) => class Layer extends decorate(JsonResource) {
// return this.tileEntities[index];
// }
toJSON() {
return {
entities: this.entityList.toJSON(),
tilesetUri: this.tileset.uri,
tiles: this.tiles.toJSON(),
};
}
toNetwork(informed) {
return {
entities: this.entityList.toNetwork(informed),

View File

@ -108,7 +108,7 @@ export default () => class Tiles extends decorate(Class) {
return index < 0 || index >= this.data.length ? undefined : this.data[index];
}
toNetwork() {
toJSON() {
return {
size: this.size,
data: this.data,