fix component start()

beta.r3js.org
-=yb4f310 2017-11-14 12:47:45 +01:00
parent dcfeca57d7
commit 643e956052
1 changed files with 28 additions and 4 deletions

View File

@ -31,6 +31,15 @@ GameLib.System.CustomCode.prototype.start = function() {
GameLib.System.prototype.start.call(this);
GameLib.EntityManager.Instance.queryComponents(GameLib.D3.CustomCode).map(
function(component) {
this.subscriptions[component.id] = GameLib.Event.Subscribe(
component.eventId,
component.instance
);
}.bind(this)
);
this.instanceCreatedSubscription = GameLib.Event.Subscribe(
GameLib.Event.INSTANCE_CREATED,
this.instanceCreated.bind(this)
@ -105,10 +114,25 @@ GameLib.System.CustomCode.prototype.stop = function() {
GameLib.System.prototype.stop.call(this);
this.instanceCreatedSubscription.remove();
this.removeComponentSubscription.remove();
this.compileSuccessSubscription.remove();
this.compileFailedSubscription.remove();
if (this.instanceCreatedSubscription) {
this.instanceCreatedSubscription.remove();
this.instanceCreatedSubscription = null;
}
if (this.removeComponentSubscription) {
this.removeComponentSubscription.remove();
this.removeComponentSubscription = null;
}
if (this.compileSuccessSubscription) {
this.compileSuccessSubscription.remove();
this.compileSuccessSubscription = null;
}
if (this.compileFailedSubscription) {
this.compileFailedSubscription.remove();
this.compileFailedSubscription = null;
}
Object.keys(this.subscriptions).map(
function(componentId) {