fix component start()
parent
dcfeca57d7
commit
643e956052
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue