diff --git a/packages/behavior/traits/behaved.trait.js b/packages/behavior/traits/behaved.trait.js index c3db5b1..d1c0e59 100644 --- a/packages/behavior/traits/behaved.trait.js +++ b/packages/behavior/traits/behaved.trait.js @@ -1,4 +1,4 @@ -import {compose} from '@avocado/core'; +import {compose, flatten} from '@avocado/core'; import {StateProperty, Trait} from '@avocado/entity'; import {Context} from '../context'; @@ -24,7 +24,6 @@ export default class Behaved extends decorate(Trait) { static defaultParams() { return { - contextTypeHints: {}, routines: {}, }; } @@ -38,10 +37,6 @@ export default class Behaved extends decorate(Trait) { static describeParams() { return { - contextTypeHints: { - type: 'object', - label: 'Context type hints', - }, routines: { type: 'routines', label: 'Routines', @@ -71,8 +66,6 @@ export default class Behaved extends decorate(Trait) { this._context = new Context({ entity: [this.entity, 'entity'], }); - Object.entries(this.params.contextTypeHints) - .forEach(([key, type]) => this._context.add(key, undefined, type)); this._currentRoutine = undefined; this._routines = (new Routines()).fromJSON(this.params.routines); this.updateCurrentRoutine(this.state.currentRoutine); @@ -103,6 +96,12 @@ export default class Behaved extends decorate(Trait) { this.entity.isBehaving = !isDying; }, + traitAdded: (type) => { + console.log(flatten(this.entity.invokeHookFlat('contextTypeHints'))) + flatten(this.entity.invokeHookFlat('contextTypeHints')) + .forEach(([key, type]) => this._context.add(key, undefined, type)); + }, + }; }