diff --git a/packages/entity/traits/spawner.trait.js b/packages/entity/traits/spawner.trait.js index 47e5a77..b682952 100644 --- a/packages/entity/traits/spawner.trait.js +++ b/packages/entity/traits/spawner.trait.js @@ -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'; } diff --git a/packages/sound/traits/audible.trait.js b/packages/sound/traits/audible.trait.js index 87772a9..b9faf93 100644 --- a/packages/sound/traits/audible.trait.js +++ b/packages/sound/traits/audible.trait.js @@ -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}), {}); + } + }