chore: options

This commit is contained in:
cha0s 2020-06-25 04:58:09 -05:00
parent 81469233d4
commit 37613ffec1
2 changed files with 13 additions and 4 deletions

View File

@ -14,8 +14,6 @@ const decorate = compose(
export default class Spawner extends decorate(Trait) {
static behaviorTypes() {
const spawnKeys = (entity) => Object.keys(entity.traitInstance('spawner').params.spawns)
.reduce((r, key) => ({...r, [key]: key}), {})
return {
killAllChildren: {
type: 'void',
@ -28,7 +26,7 @@ export default class Spawner extends decorate(Trait) {
args: [
['key', {
type: 'string',
options: spawnKeys,
options: (entity) => this.optionsForSpawn(entity),
}],
['json', {
type: 'object',
@ -42,7 +40,7 @@ export default class Spawner extends decorate(Trait) {
args: [
['key', {
type: 'string',
options: spawnKeys,
options: (entity) => this.optionsForSpawn(entity),
}],
['position', {
type: 'vector',
@ -113,6 +111,11 @@ export default class Spawner extends decorate(Trait) {
};
}
static optionsForSpawn(entity) {
return Object.keys(entity.traitInstance('spawner').params.spawns)
.reduce((r, key) => ({...r, [key]: key}), {});
}
static type() {
return 'spawner';
}

View File

@ -21,6 +21,7 @@ export default class Audible extends Trait {
args: [
['key', {
type: 'string',
options: (entity) => this.optionsForSounds(entity),
}],
],
},
@ -101,4 +102,9 @@ export default class Audible extends Trait {
};
}
static optionsForSounds(entity) {
return Object.keys(entity.traitInstance('audible').params.sounds)
.reduce((r, key) => ({...r, [key]: key}), {});
}
}