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 debug = D('@avocado:behavior:context');
|
||||
|
||||
class Context extends Map {
|
||||
class Context {
|
||||
|
||||
constructor() {
|
||||
this.map = new Map();
|
||||
}
|
||||
|
||||
add(key, value) {
|
||||
this.set(key, value);
|
||||
this.map.set(key, value);
|
||||
}
|
||||
|
||||
clear() {
|
||||
super.clear();
|
||||
this.map.clear();
|
||||
this.add('context', this);
|
||||
this.add('Flow', Flow);
|
||||
this.add('Math', MathExt);
|
||||
|
@ -38,7 +42,7 @@ class Context extends Map {
|
|||
}
|
||||
|
||||
destroy() {
|
||||
super.clear();
|
||||
this.map.clear();
|
||||
}
|
||||
|
||||
static renderSteps(steps) {
|
||||
|
@ -96,7 +100,7 @@ class Context extends Map {
|
|||
previousNode = node;
|
||||
return result;
|
||||
});
|
||||
}, this.get(first.key));
|
||||
}, this.map.get(first.key));
|
||||
}
|
||||
|
||||
traverseOneStep(steps, previousNode, node, step) {
|
||||
|
|
|
@ -65,8 +65,8 @@ export class Collider extends decorate(Trait) {
|
|||
pushActionBundle(paramActions, other) {
|
||||
const actions = behaviorItemFromJSON(paramActions);
|
||||
const context = createContext();
|
||||
context.set('entity', this.entity);
|
||||
context.set('other', other);
|
||||
context.add('entity', this.entity);
|
||||
context.add('other', other);
|
||||
const bundle = {
|
||||
actions,
|
||||
context,
|
||||
|
|
Loading…
Reference in New Issue
Block a user