refactor: toNet
This commit is contained in:
parent
5365608f9f
commit
03035ec8b6
|
@ -149,9 +149,12 @@ export default class Component {
|
|||
}
|
||||
}
|
||||
destroy() {}
|
||||
toJSON() {
|
||||
toNet() {
|
||||
return Component.constructor.filterDefaults(this);
|
||||
}
|
||||
toJSON() {
|
||||
return this.toNet();
|
||||
}
|
||||
};
|
||||
const properties = {};
|
||||
properties.entity = {
|
||||
|
|
|
@ -48,6 +48,11 @@ export default class EntityFactory {
|
|||
${sorted.map((type) => `${type}: this.${type}.toJSON()`).join(', ')}
|
||||
};
|
||||
`);
|
||||
Entity.prototype.toNet = new Function('', `
|
||||
return {
|
||||
${sorted.map((type) => `${type}: this.${type}.toNet()`).join(', ')}
|
||||
};
|
||||
`);
|
||||
walk.class = Entity;
|
||||
}
|
||||
return walk.class;
|
||||
|
|
|
@ -389,7 +389,7 @@ export default class Engine {
|
|||
const {id} = entity;
|
||||
lastNearby.delete(id);
|
||||
if (!memory.nearby.has(id)) {
|
||||
update[id] = entity.toJSON();
|
||||
update[id] = entity.toNet();
|
||||
if (mainEntityId === id) {
|
||||
update[id].MainEntity = {};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user