28 lines
709 B
JavaScript
28 lines
709 B
JavaScript
export function behaviorTypes() {
|
|
return {
|
|
entity: (entity) => {
|
|
const {allTraits} = require('./trait/registrar');
|
|
const Traits = entity
|
|
? Object.values(entity.allTraitInstances()).map((instance) => instance.constructor)
|
|
: allTraits();
|
|
const core = {
|
|
children: {
|
|
invokeHook: {
|
|
type: 'object',
|
|
label: 'Invoke hook.',
|
|
args: [
|
|
['hook', {
|
|
type: 'string',
|
|
}],
|
|
],
|
|
},
|
|
}
|
|
};
|
|
return Traits
|
|
.reduce((r, T) => ({
|
|
...r, children: {...r.children, ...T.behaviorTypes(), ...T.describeState()},
|
|
}), core);
|
|
},
|
|
};
|
|
}
|