chore: dependencies

This commit is contained in:
cha0s 2021-02-04 22:47:47 -06:00
parent bbdf8ea285
commit 10a3cc6160
8 changed files with 49 additions and 20 deletions

View File

@ -37,6 +37,12 @@ export default (latus) => class Pictured extends decorate(Trait) {
};
}
static dependencies() {
return [
'Visible',
];
}
static describeParams() {
return {
images: {

View File

@ -13,6 +13,12 @@ export default () => class Primitive extends Trait {
};
}
static dependencies() {
return [
'Visible',
];
}
static describeParams() {
return {
primitives: {

View File

@ -20,6 +20,12 @@ export default () => class Textual extends decorate(Trait) {
};
}
static dependencies() {
return [
'Visible',
];
}
static describeState() {
return {
text: {

View File

@ -61,6 +61,13 @@ export default (latus) => class Collider extends decorate(Trait) {
};
}
static dependencies() {
return [
'Positioned',
'Shaped',
];
}
static describe() {
return {
collidesWith: {

View File

@ -77,6 +77,12 @@ export default () => class Physical extends decorate(Trait) {
};
}
static dependencies() {
return [
'Shaped',
];
}
static describeState() {
return {
addedToPhysics: {

View File

@ -181,11 +181,15 @@ export default (latus) => class Animated extends decorate(Trait) {
traitAdded: () => {
this.setSpriteScale();
Object.keys(this.#animations).forEach((key) => {
Object.entries(this.#animations).forEach(([key, animation]) => {
const method = key === this.#currentAnimation
? 'showAnimation'
: 'hideAnimation';
this[method](key);
if (this.entity.is('Directional')) {
// eslint-disable-next-line no-param-reassign
animation.direction = this.entity.direction;
}
});
this.entity.forceUpdateBoundingBox();
},
@ -210,10 +214,6 @@ export default (latus) => class Animated extends decorate(Trait) {
animations,
(animation) => new AnimationView(animation),
);
Object.values(animations).forEach((animation) => {
// eslint-disable-next-line no-param-reassign
animation.direction = this.entity.direction;
});
Object.entries(animationViews).forEach(([key, animationView]) => {
// eslint-disable-next-line no-param-reassign
animationView.position = this.offsetFor(key);
@ -249,9 +249,6 @@ export default (latus) => class Animated extends decorate(Trait) {
if (!this.#animationViews) {
return;
}
if (!this.entity.is('Visible')) {
return;
}
const animationViews = Object.values(this.#animationViews);
for (let i = 0; i < animationViews.length; i++) {
animationViews[i].scale = this.entity.rawVisibleScale;

View File

@ -12,6 +12,13 @@ export default () => class Followed extends Trait {
};
}
static dependencies() {
return [
'Positioned',
'Roomed',
];
}
static describeParams() {
return {
viewSize: {
@ -22,9 +29,6 @@ export default () => class Followed extends Trait {
}
destroy() {
if (!this.entity.is('Roomed')) {
return;
}
const {room} = this.entity;
if (room) {
room.off('sizeChanged', this.onRoomSizeChanged);
@ -36,9 +40,6 @@ export default () => class Followed extends Trait {
}
onRoomSizeChanged() {
if (!this.entity.is('Roomed')) {
return;
}
const {room} = this.entity;
if (room) {
this.#camera.areaSize = room.size;
@ -46,9 +47,6 @@ export default () => class Followed extends Trait {
}
updatePosition() {
if (!this.entity.is('Positioned')) {
return;
}
this.#camera.position = this.entity.position;
}

View File

@ -29,6 +29,12 @@ export default () => class Layered extends Trait {
};
}
static dependencies() {
return [
'Positioned',
];
}
destroy() {
this.entity.removeFromLayer();
}
@ -56,9 +62,6 @@ export default () => class Layered extends Trait {
if (!layer) {
return;
}
if (!this.entity.is('Positioned')) {
return;
}
const {tileset} = layer;
if (!tileset) {
return;