refactor: don't extend Map for Context
This commit is contained in:
parent
ac9ca7c5a5
commit
60a091a6d9
|
@ -12,14 +12,18 @@ import * as Utility from './utility';
|
||||||
const compiled = new Map();
|
const compiled = new Map();
|
||||||
const debug = D('@avocado:behavior:context');
|
const debug = D('@avocado:behavior:context');
|
||||||
|
|
||||||
class Context extends Map {
|
class Context {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.map = new Map();
|
||||||
|
}
|
||||||
|
|
||||||
add(key, value) {
|
add(key, value) {
|
||||||
this.set(key, value);
|
this.map.set(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
super.clear();
|
this.map.clear();
|
||||||
this.add('context', this);
|
this.add('context', this);
|
||||||
this.add('Flow', Flow);
|
this.add('Flow', Flow);
|
||||||
this.add('Math', MathExt);
|
this.add('Math', MathExt);
|
||||||
|
@ -38,7 +42,7 @@ class Context extends Map {
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
super.clear();
|
this.map.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static renderSteps(steps) {
|
static renderSteps(steps) {
|
||||||
|
@ -96,7 +100,7 @@ class Context extends Map {
|
||||||
previousNode = node;
|
previousNode = node;
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
}, this.get(first.key));
|
}, this.map.get(first.key));
|
||||||
}
|
}
|
||||||
|
|
||||||
traverseOneStep(steps, previousNode, node, step) {
|
traverseOneStep(steps, previousNode, node, step) {
|
||||||
|
|
|
@ -65,8 +65,8 @@ export class Collider extends decorate(Trait) {
|
||||||
pushActionBundle(paramActions, other) {
|
pushActionBundle(paramActions, other) {
|
||||||
const actions = behaviorItemFromJSON(paramActions);
|
const actions = behaviorItemFromJSON(paramActions);
|
||||||
const context = createContext();
|
const context = createContext();
|
||||||
context.set('entity', this.entity);
|
context.add('entity', this.entity);
|
||||||
context.set('other', other);
|
context.add('other', other);
|
||||||
const bundle = {
|
const bundle = {
|
||||||
actions,
|
actions,
|
||||||
context,
|
context,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user