refactor: Behavior items derive type/name

This commit is contained in:
cha0s 2019-04-16 17:58:49 -05:00
parent e63766b045
commit ab937f2206
10 changed files with 6 additions and 33 deletions

View File

@ -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

View File

@ -2,10 +2,6 @@ import {Traversal} from './traversal';
export class Action extends Traversal {
static type() {
return 'action';
}
toJSON() {
return {
...super.toJSON(),

View File

@ -10,10 +10,6 @@ const decorate = compose(
export class Actions extends decorate(Traversals) {
static type() {
return 'actions';
}
constructor() {
super();
this._index = 0;

View File

@ -4,10 +4,6 @@ export function Collection(type) {
const plural = `${type}s`;
return class Collection {
static type() {
return plural;
}
constructor() {
this[plural] = [];
}

View File

@ -2,10 +2,6 @@ import {fromJSON as behaviorItemFromJSON} from './registry';
export class Condition {
static type() {
return 'condition';
}
constructor() {
this.operator = '';
this.operands = [];

View File

@ -1,9 +1,5 @@
export class Literal {
static type() {
return 'literal';
}
constructor() {
this.value = null;
}

View File

@ -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);
}

View File

@ -2,10 +2,6 @@ import {Actions} from './actions';
export class Routine {
static type() {
return 'routine';
}
constructor() {
this._context = undefined;
this.actions = new Actions();

View File

@ -2,10 +2,6 @@ import {Routine} from './routine';
export class Routines {
static type() {
return 'routines';
}
constructor() {
this._context = undefined;
this.routines = {};

View File

@ -2,10 +2,6 @@ import {fromJSON as behaviorItemFromJSON} from './registry';
export class Traversal {
static type() {
return 'traversal';
}
constructor() {
this.hash = undefined;
this.steps = [];