perf: inline entity from JSON

This commit is contained in:
cha0s 2019-05-04 11:39:23 -05:00
parent 28b1312f40
commit a66b6889f2
2 changed files with 6 additions and 3 deletions

View File

@ -56,7 +56,7 @@ const decorate = compose(
export class Entity extends decorate(Resource) {
constructor() {
constructor(json) {
super();
this._hooks = {};
this.isDirty = true;
@ -69,6 +69,9 @@ export class Entity extends decorate(Resource) {
this.removeAllTraits();
});
this.initializeSynchronizedChildren();
if ('undefined' !== typeof json) {
this.fromJSON(json);
}
}
acceptPacket(packet) {

View File

@ -94,8 +94,8 @@ export class Layer extends decorate(class {}) {
fromJSON(json) {
if (json.entities) {
json.entities.forEach((entityJSON) => {
const entity = new Entity();
this.entityList.addEntity(entity.fromJSON(entityJSON));
const entity = new Entity(entityJSON);
this.entityList.addEntity(entity);
});
}
if (json.tiles) {