refactor: Behavior items derive type/name
This commit is contained in:
parent
e63766b045
commit
ab937f2206
2
TODO.md
2
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
|
||||
|
|
|
@ -2,10 +2,6 @@ import {Traversal} from './traversal';
|
|||
|
||||
export class Action extends Traversal {
|
||||
|
||||
static type() {
|
||||
return 'action';
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
...super.toJSON(),
|
||||
|
|
|
@ -10,10 +10,6 @@ const decorate = compose(
|
|||
|
||||
export class Actions extends decorate(Traversals) {
|
||||
|
||||
static type() {
|
||||
return 'actions';
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this._index = 0;
|
||||
|
|
|
@ -4,10 +4,6 @@ export function Collection(type) {
|
|||
const plural = `${type}s`;
|
||||
return class Collection {
|
||||
|
||||
static type() {
|
||||
return plural;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this[plural] = [];
|
||||
}
|
||||
|
|
|
@ -2,10 +2,6 @@ import {fromJSON as behaviorItemFromJSON} from './registry';
|
|||
|
||||
export class Condition {
|
||||
|
||||
static type() {
|
||||
return 'condition';
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.operator = '';
|
||||
this.operands = [];
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
export class Literal {
|
||||
|
||||
static type() {
|
||||
return 'literal';
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.value = null;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -2,10 +2,6 @@ import {Actions} from './actions';
|
|||
|
||||
export class Routine {
|
||||
|
||||
static type() {
|
||||
return 'routine';
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this._context = undefined;
|
||||
this.actions = new Actions();
|
||||
|
|
|
@ -2,10 +2,6 @@ import {Routine} from './routine';
|
|||
|
||||
export class Routines {
|
||||
|
||||
static type() {
|
||||
return 'routines';
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this._context = undefined;
|
||||
this.routines = {};
|
||||
|
|
|
@ -2,10 +2,6 @@ import {fromJSON as behaviorItemFromJSON} from './registry';
|
|||
|
||||
export class Traversal {
|
||||
|
||||
static type() {
|
||||
return 'traversal';
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.hash = undefined;
|
||||
this.steps = [];
|
||||
|
|
Loading…
Reference in New Issue
Block a user