@robotlegsjs/phaser
Version:
RobotlegsJS integration with Phaser Scene Manager
131 lines • 4.75 kB
JavaScript
;
// ------------------------------------------------------------------------------
// Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved.
//
// NOTICE: You are permitted to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------
Object.defineProperty(exports, "__esModule", { value: true });
exports.SceneManagerBinding = void 0;
var tslib_1 = require("tslib");
var core_1 = require("@robotlegsjs/core");
var SceneManagerBindingEvent_1 = require("./SceneManagerBindingEvent");
/**
* @private
*/
var SceneManagerBinding = /** @class */ (function (_super) {
tslib_1.__extends(SceneManagerBinding, _super);
/*============================================================================*/
/* Constructor */
/*============================================================================*/
/**
* @private
*/
function SceneManagerBinding(sceneManager) {
var _this = _super.call(this) || this;
/*============================================================================*/
/* Private Properties */
/*============================================================================*/
_this._sceneHandlers = [];
_this._viewHandlers = [];
_this._sceneManager = sceneManager;
return _this;
}
Object.defineProperty(SceneManagerBinding.prototype, "parent", {
/**
* @private
*/
get: function () {
return this._parent;
},
/**
* @private
*/
set: function (value) {
this._parent = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(SceneManagerBinding.prototype, "sceneManager", {
/**
* @private
*/
get: function () {
return this._sceneManager;
},
enumerable: false,
configurable: true
});
/*============================================================================*/
/* Public Functions */
/*============================================================================*/
/**
* @private
*/
SceneManagerBinding.prototype.addSceneHandler = function (handler) {
if (this._sceneHandlers.indexOf(handler) > -1) {
return;
}
this._sceneHandlers.push(handler);
};
/**
* @private
*/
SceneManagerBinding.prototype.removeSceneHandler = function (handler) {
var index = this._sceneHandlers.indexOf(handler);
if (index > -1) {
this._sceneHandlers.splice(index, 1);
this._dispatchBindingEmpty();
}
};
/**
* @private
*/
SceneManagerBinding.prototype.addViewHandler = function (handler) {
if (this._viewHandlers.indexOf(handler) > -1) {
return;
}
this._viewHandlers.push(handler);
};
/**
* @private
*/
SceneManagerBinding.prototype.removeViewHandler = function (handler) {
var index = this._viewHandlers.indexOf(handler);
if (index > -1) {
this._viewHandlers.splice(index, 1);
this._dispatchBindingEmpty();
}
};
/**
* @private
*/
SceneManagerBinding.prototype.handleScene = function (scene, type) {
this._sceneHandlers.forEach(function (handler) {
handler.handleScene(scene, type);
});
};
/**
* @private
*/
SceneManagerBinding.prototype.handleView = function (view, type) {
this._viewHandlers.forEach(function (handler) {
handler.handleView(view, type);
});
};
/*============================================================================*/
/* Private Functions */
/*============================================================================*/
/**
* @private
*/
SceneManagerBinding.prototype._dispatchBindingEmpty = function () {
if (this._sceneHandlers.length === 0 && this._viewHandlers.length === 0) {
this.dispatchEvent(new SceneManagerBindingEvent_1.SceneManagerBindingEvent(SceneManagerBindingEvent_1.SceneManagerBindingEvent.BINDING_EMPTY));
}
};
return SceneManagerBinding;
}(core_1.EventDispatcher));
exports.SceneManagerBinding = SceneManagerBinding;
//# sourceMappingURL=SceneManagerBinding.js.map