fix: loading

This commit is contained in:
cha0s 2021-01-19 14:59:51 -06:00
parent 3d45055640
commit d2bb1273ac
21 changed files with 44 additions and 41 deletions

View File

@ -86,8 +86,8 @@ export default (latus) => class Behaved extends decorate(Trait) {
this.#routines = undefined;
}
load(json) {
super.load(json);
async load(json) {
await super.load(json);
this.#context = new Context(
{
entity: [this.entity, 'entity'],

View File

@ -98,7 +98,7 @@ export default (latus) => class EntityList extends decorate(JsonResource) {
}
async load(json = []) {
super.load(json);
await super.load(json);
const {fromResourceType: {Entity}} = resource(latus);
const entityInstances = await Promise.all(json.map((entity) => Entity.load(entity)));
for (let i = 0; i < entityInstances.length; i++) {

View File

@ -160,8 +160,8 @@ export default (latus) => class Alive extends decorate(Trait) {
};
}
load(json) {
super.load(json);
async load(json) {
await super.load(json);
this.#context = new Context(
{
entity: [this.entity, 'entity'],

View File

@ -64,8 +64,8 @@ export default () => class Listed extends Trait {
};
}
load(json) {
super.load(json);
async load(json) {
await super.load(json);
this.entity.list = null;
}

View File

@ -30,8 +30,8 @@ export default () => class Perishable extends decorate(Trait) {
};
}
load(json) {
super.load(json);
async load(json) {
await super.load(json);
this.#ttl = this.params.ttl;
}

View File

@ -74,8 +74,8 @@ export default () => class Positioned extends decorate(Trait) {
}
}
load(json) {
super.load(json);
async load(json) {
await super.load(json);
const {x, y} = this.state;
this.trackedPosition = [x, y];
this.entity.position[0] = x;

View File

@ -144,7 +144,7 @@ export default (latus) => class Pictured extends decorate(Trait) {
}
async load(json = {}) {
super.load(json);
await super.load(json);
if (Object.keys(this.params.images).length > 0) {
const {fromResourceType: {Image}} = resource(latus);
const sprites = await mapValuesAsync(

View File

@ -195,8 +195,8 @@ export default () => class Visible extends decorate(Trait) {
};
}
load(json) {
super.load(json);
async load(json) {
await super.load(json);
if ('client' === process.env.SIDE) {
const {filter} = this.params;
if (filter) {

View File

@ -8,7 +8,7 @@ const decorate = compose(
StateProperty('isColliding'),
);
export default () => class Collider extends decorate(Trait) {
export default (latus) => class Collider extends decorate(Trait) {
#collidesWithGroups = [];
@ -217,8 +217,8 @@ export default () => class Collider extends decorate(Trait) {
return this.#isSensor;
}
load(load) {
super.load(load);
async load(load) {
await super.load(load);
const {
collidesWithGroups,
collisionEndActions,
@ -238,10 +238,13 @@ export default () => class Collider extends decorate(Trait) {
}
pushCollisionTickingPromise(actions, other) {
const context = new Context({
entity: [this.entity, 'entity'],
other: [other, 'entity'],
});
const context = new Context(
{
entity: [this.entity, 'entity'],
other: [other, 'entity'],
},
latus,
);
this.entity.addTickingPromise(actions.tickingPromise(context));
}

View File

@ -138,8 +138,8 @@ export default () => class Emitted extends decorate(Trait) {
return !!this.params.transient;
}
load(json) {
super.load(json);
async load(json) {
await super.load(json);
this.#alphaStart = new Range(this.params.alpha.start);
this.#alphaEnd = new Range(this.params.alpha.end);
this.#force = new Vector.Range(this.params.force);

View File

@ -56,8 +56,8 @@ export default () => class Shaped extends decorate(Trait) {
};
}
load(json) {
super.load(json);
async load(json) {
await super.load(json);
this.#shape = shapeFromJSON(this.params.shape);
}

View File

@ -9,15 +9,15 @@ Resource.root = 'test/fixtures';
JsonResource.root = 'test/fixtures';
class ResourceSubclass extends Resource {
load(buffer) {
super.load(buffer);
async load(buffer) {
await super.load(buffer);
this.buffer = buffer;
}
}
class JsonResourceSubclass extends JsonResource {
load(json) {
super.load(json);
async load(json) {
await super.load(json);
this.json = json;
}
}

View File

@ -17,7 +17,7 @@ export default () => class Sound extends JsonResource {
}
async load(json = {}) {
super.load(json);
await super.load(json);
const {interval = 0, volume = 1} = json;
this.interval = interval;
this.originalVolume = volume;

View File

@ -64,8 +64,8 @@ export default (latus) => class Audible extends Trait {
return extended;
}
load(json) {
super.load(json);
async load(json) {
await super.load(json);
if (json.sounds) {
this.#sounds = json.sounds;
}

View File

@ -200,7 +200,7 @@ export default (latus) => class Animated extends decorate(Trait) {
}
async load(json) {
super.load(json);
await super.load(json);
if (Object.keys(json.params.animations).length > 0) {
const {fromResourceType: {Animation}} = resource(latus);
const animations = await mapValuesAsync(

View File

@ -91,7 +91,7 @@ export default (latus) => class Layer extends decorate(JsonResource) {
}
async load(json = {}) {
super.load(json);
await super.load(json);
const {
entities,
tiles,

View File

@ -82,7 +82,7 @@ export default (latus) => class Layers extends decorate(JsonResource) {
}
async load(json = []) {
super.load(json);
await super.load(json);
this.removeAllLayers();
const {fromResourceType: {Layer}} = resource(latus);
const layers = await Promise.all(json.map((layer) => Layer.load(layer)));

View File

@ -64,7 +64,7 @@ export default (latus) => class Room extends decorate(JsonResource) {
}
async load(json = {}) {
super.load(json);
await super.load(json);
const {layers, size} = json;
if (size) {
this.size = size;

View File

@ -38,7 +38,7 @@ export default () => class Tileset extends decorate(JsonResource) {
}
async load(json = {}) {
super.load(json);
await super.load(json);
const {imageUri, tileSize} = json;
if (imageUri) {
this.image = await Image.load(imageUri);

View File

@ -72,8 +72,8 @@ export default () => class Followed extends Trait {
};
}
load(json) {
super.load(json);
async load(json) {
await super.load(json);
this.#camera.viewSize = this.params.viewSize;
this.updatePosition();
this.onRoomSizeChanged();

View File

@ -41,8 +41,8 @@ export default () => class Layered extends Trait {
return this.#tileOffset;
}
load(json) {
super.load(json);
async load(json) {
await super.load(json);
this.entity.layer = null;
this.setCurrentTileFromLayer();
}