delayed instance encounterer
parent
5f56558f00
commit
6b69ea23e6
|
@ -93,7 +93,7 @@ GameLib.Event.TOUCH_MOVE = 0x4b;
|
|||
GameLib.Event.TOUCH_CANCEL = 0x4c;
|
||||
GameLib.Event.GET_REMOTE_API_URL = 0x4d;
|
||||
GameLib.Event.GET_GRAPHICS_IMPLEMENTATION = 0x4e;
|
||||
GameLib.Event.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX = 0x4f;
|
||||
GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED = 0x4f;
|
||||
GameLib.Event.GET_CODER_IMPLEMENTATION = 0x50;
|
||||
GameLib.Event.ANIMATION_MESH_ADDED = 0x51;
|
||||
GameLib.Event.ANIMATION_MESH_REMOVED = 0x52;
|
||||
|
@ -195,7 +195,7 @@ GameLib.Event.GetEventName = function(number) {
|
|||
case 0x4c : return 'touch_cancel';
|
||||
case 0x4d : return 'get_remote_api_url';
|
||||
case 0x4e : return 'get_graphics_implementation';
|
||||
case 0x4f : return 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';
|
||||
case 0x4f : return 'delayed_instance_encountered';
|
||||
case 0x50 : return 'get_coder_implementation';
|
||||
case 0x51 : return 'animation_mesh_added';
|
||||
case 0x52 : return 'animation_mesh_removed';
|
||||
|
|
|
@ -111,6 +111,17 @@ GameLib.Component.prototype.performInstanceCreation = function() {
|
|||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Some systems require a restart in order to create the delayed components (like System.Input for
|
||||
* Edit Controls) - we need to give them the opportunity to restart
|
||||
*/
|
||||
GameLib.Event.Emit(
|
||||
GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED,
|
||||
{
|
||||
component : this
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -55,6 +55,8 @@ GameLib.System.Input = function(
|
|||
this.keyDown = this.onKeyDown.bind(this);
|
||||
this.keyUp = this.onKeyUp.bind(this);
|
||||
|
||||
this.delayedInstanceEncounteredSubscription = null;
|
||||
|
||||
this.mouse = new GameLib.Mouse(
|
||||
graphics
|
||||
)
|
||||
|
@ -78,6 +80,13 @@ GameLib.System.Input.prototype.start = function() {
|
|||
|
||||
this.mouseControls = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Controls.Mouse);
|
||||
|
||||
this.delayedInstanceEncounteredSubscription = GameLib.Event.Subscribe(
|
||||
GameLib.Event.DELAYED_INSTANCE_ENCOUNTERED,
|
||||
function() {
|
||||
this.restart();
|
||||
}.bind(this)
|
||||
);
|
||||
|
||||
/**
|
||||
* If we have touch controls - inject them first so we can override editor controls if necessary
|
||||
*/
|
||||
|
@ -588,6 +597,8 @@ GameLib.System.Input.prototype.stop = function() {
|
|||
|
||||
GameLib.System.prototype.stop.call(this);
|
||||
|
||||
this.delayedInstanceEncounteredSubscription.remove();
|
||||
|
||||
if (this.editorControls.length > 0) {
|
||||
/**
|
||||
* Now remove all input capabilities
|
||||
|
|
Loading…
Reference in New Issue