Skip to content

Instantly share code, notes, and snippets.

@AGoblinKing
Created January 9, 2015 01:28
Show Gist options
  • Save AGoblinKing/196442c60fdc9698aa79 to your computer and use it in GitHub Desktop.
Save AGoblinKing/196442c60fdc9698aa79 to your computer and use it in GitHub Desktop.
Component = {
entitiesAttached : [],
call : function(message) {
// first give the component a shot
if(typeof this[message.n] === "function") {
this[message.n](message);
}
// then its attached versions
if(typeof this.e[message.n] === "function") {
this.entitiesAttached.forEach(function(e) {
e.call(message);
});
}
}
};
World = {
broadcast : function(message) {
Object.keys(Vx.components).forEach(function(name) {
var c = Vx.components[name];
c.call(message);
});
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment