react-simple-game-engine
Version:
[WIP] not able to use in currently. <!-- Document cumming soon... -->
78 lines (77 loc) • 3.38 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { Entity } from "./entities/entity";
import { EntitySuit } from "./entities/entity-suit";
var LogicComponent = /** @class */ (function () {
function LogicComponent(configurable, _isPrefab) {
this.configurable = configurable;
this._isPrefab = _isPrefab;
this.layerIndex = 0;
}
Object.defineProperty(LogicComponent.prototype, "isPrefab", {
get: function () {
return this._isPrefab;
},
enumerable: false,
configurable: true
});
Object.defineProperty(LogicComponent.prototype, "worldManagement", {
set: function (_worldManagement) {
if (this._worldManagement) {
console.warn("Cant change worldManagement");
}
else {
this._worldManagement = _worldManagement;
}
},
enumerable: false,
configurable: true
});
LogicComponent.prototype.output = function (_a) {
if (_a === void 0) { _a = {}; }
var worldManagement = _a.worldManagement, targetParams = __rest(_a, ["worldManagement"]);
var configurable = this.configurable;
var _b = Array.isArray(configurable)
? configurable
: [configurable], Class = _b[0], _c = _b[1], params = _c === void 0 ? {} : _c;
var c = new Class();
if (worldManagement) {
this.worldManagement = worldManagement;
}
if (c instanceof EntitySuit) {
c["_layerIndex"] = this.layerIndex; // use _layerIndex to not trigger change index process at this step
c.preInitial(this._worldManagement);
}
if (c instanceof Entity) {
var _d = params, transform = _d.transform, bodyOptions = _d.bodyOptions, props = _d.props, restParams = __rest(_d, ["transform", "bodyOptions", "props"]);
var extraTransform = targetParams.transform, extraBodyOptions = targetParams.bodyOptions, extraProps = targetParams.props, extraRestParams = __rest(targetParams, ["transform", "bodyOptions", "props"]);
c.initial(__assign(__assign({ transform: __assign(__assign({}, transform), extraTransform), bodyOptions: __assign(__assign({}, bodyOptions), extraBodyOptions), props: __assign(__assign({}, props), extraProps) }, restParams), extraRestParams));
}
else {
c.initial(__assign(__assign({}, params), targetParams));
}
return c;
};
return LogicComponent;
}());
export { LogicComponent };