diff --git a/TODO.md b/TODO.md index f629f76..94848f1 100644 --- a/TODO.md +++ b/TODO.md @@ -2,7 +2,7 @@ - ✔ Remove dependency on decorators - ✔ Synchronized should be a mixin -- ❌ Behavior items should derive type/name +- ✔ Behavior items should derive type/name - ✔ Precompile behavior traversals - ❌ Abstract physics world tick (no destructuring) - ❌ Cache current routine for Behaved tick diff --git a/packages/behavior/item/action.js b/packages/behavior/item/action.js index 6e567cf..582f8c2 100644 --- a/packages/behavior/item/action.js +++ b/packages/behavior/item/action.js @@ -2,10 +2,6 @@ import {Traversal} from './traversal'; export class Action extends Traversal { - static type() { - return 'action'; - } - toJSON() { return { ...super.toJSON(), diff --git a/packages/behavior/item/actions.js b/packages/behavior/item/actions.js index 950bdae..ef3b8be 100644 --- a/packages/behavior/item/actions.js +++ b/packages/behavior/item/actions.js @@ -10,10 +10,6 @@ const decorate = compose( export class Actions extends decorate(Traversals) { - static type() { - return 'actions'; - } - constructor() { super(); this._index = 0; diff --git a/packages/behavior/item/collection.js b/packages/behavior/item/collection.js index b7e03e2..08637d5 100644 --- a/packages/behavior/item/collection.js +++ b/packages/behavior/item/collection.js @@ -4,10 +4,6 @@ export function Collection(type) { const plural = `${type}s`; return class Collection { - static type() { - return plural; - } - constructor() { this[plural] = []; } diff --git a/packages/behavior/item/condition.js b/packages/behavior/item/condition.js index e526770..124419a 100644 --- a/packages/behavior/item/condition.js +++ b/packages/behavior/item/condition.js @@ -2,10 +2,6 @@ import {fromJSON as behaviorItemFromJSON} from './registry'; export class Condition { - static type() { - return 'condition'; - } - constructor() { this.operator = ''; this.operands = []; diff --git a/packages/behavior/item/literal.js b/packages/behavior/item/literal.js index 7124f2d..755507c 100644 --- a/packages/behavior/item/literal.js +++ b/packages/behavior/item/literal.js @@ -1,9 +1,5 @@ export class Literal { - static type() { - return 'literal'; - } - constructor() { this.value = null; } diff --git a/packages/behavior/item/registry.js b/packages/behavior/item/registry.js index 08378e8..c3b4587 100644 --- a/packages/behavior/item/registry.js +++ b/packages/behavior/item/registry.js @@ -13,5 +13,10 @@ export function deregister(BehaviorItem) { } export function register(BehaviorItem) { + if (!BehaviorItem.type) { + BehaviorItem.type = function() { + return BehaviorItem.name.toLowerCase(); + } + } behaviorItemRegistry.set(BehaviorItem.type(), BehaviorItem); } diff --git a/packages/behavior/item/routine.js b/packages/behavior/item/routine.js index 16d6b13..ac5612f 100644 --- a/packages/behavior/item/routine.js +++ b/packages/behavior/item/routine.js @@ -2,10 +2,6 @@ import {Actions} from './actions'; export class Routine { - static type() { - return 'routine'; - } - constructor() { this._context = undefined; this.actions = new Actions(); diff --git a/packages/behavior/item/routines.js b/packages/behavior/item/routines.js index eab4f87..3afc040 100644 --- a/packages/behavior/item/routines.js +++ b/packages/behavior/item/routines.js @@ -2,10 +2,6 @@ import {Routine} from './routine'; export class Routines { - static type() { - return 'routines'; - } - constructor() { this._context = undefined; this.routines = {}; diff --git a/packages/behavior/item/traversal.js b/packages/behavior/item/traversal.js index 69778b4..f83eeeb 100644 --- a/packages/behavior/item/traversal.js +++ b/packages/behavior/item/traversal.js @@ -2,10 +2,6 @@ import {fromJSON as behaviorItemFromJSON} from './registry'; export class Traversal { - static type() { - return 'traversal'; - } - constructor() { this.hash = undefined; this.steps = [];