fix component start()
parent
dcfeca57d7
commit
643e956052
|
@ -31,6 +31,15 @@ GameLib.System.CustomCode.prototype.start = function() {
|
||||||
|
|
||||||
GameLib.System.prototype.start.call(this);
|
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(
|
this.instanceCreatedSubscription = GameLib.Event.Subscribe(
|
||||||
GameLib.Event.INSTANCE_CREATED,
|
GameLib.Event.INSTANCE_CREATED,
|
||||||
this.instanceCreated.bind(this)
|
this.instanceCreated.bind(this)
|
||||||
|
@ -105,10 +114,25 @@ GameLib.System.CustomCode.prototype.stop = function() {
|
||||||
|
|
||||||
GameLib.System.prototype.stop.call(this);
|
GameLib.System.prototype.stop.call(this);
|
||||||
|
|
||||||
|
if (this.instanceCreatedSubscription) {
|
||||||
this.instanceCreatedSubscription.remove();
|
this.instanceCreatedSubscription.remove();
|
||||||
|
this.instanceCreatedSubscription = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.removeComponentSubscription) {
|
||||||
this.removeComponentSubscription.remove();
|
this.removeComponentSubscription.remove();
|
||||||
|
this.removeComponentSubscription = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.compileSuccessSubscription) {
|
||||||
this.compileSuccessSubscription.remove();
|
this.compileSuccessSubscription.remove();
|
||||||
|
this.compileSuccessSubscription = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.compileFailedSubscription) {
|
||||||
this.compileFailedSubscription.remove();
|
this.compileFailedSubscription.remove();
|
||||||
|
this.compileFailedSubscription = null;
|
||||||
|
}
|
||||||
|
|
||||||
Object.keys(this.subscriptions).map(
|
Object.keys(this.subscriptions).map(
|
||||||
function(componentId) {
|
function(componentId) {
|
||||||
|
|
Loading…
Reference in New Issue