refactor: don't extend Map for Context

This commit is contained in:
cha0s 2019-09-08 04:08:29 -05:00
parent ac9ca7c5a5
commit 60a091a6d9
2 changed files with 11 additions and 7 deletions

View File

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

View File

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