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

View File

@ -21,6 +21,7 @@ export default class Audible extends Trait {
args: [ args: [
['key', { ['key', {
type: 'string', 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}), {});
}
} }