r3-legacy/src/game-lib-api-custom-code.js

46 lines
939 B
JavaScript

/**
* Custom Code Component
* @param id
* @param name
* @param eventId
* @param code
* @param parentEntity
* @constructor
*/
GameLib.API.CustomCode = function (
id,
name,
eventId,
code,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'CustomCode (' + this.id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(eventId)) {
eventId = 42;
}
this.eventId = eventId;
if (GameLib.Utils.UndefinedOrNull(code)) {
code = "return null;\n//@ sourceURL=" + this.name + ".js";
}
this.code = code;
GameLib.API.Component.call(
this,
GameLib.Component.CUSTOM_CODE,
parentEntity
);
};
GameLib.API.CustomCode.prototype = Object.create(GameLib.API.Component.prototype);
GameLib.API.CustomCode.prototype.constructor = GameLib.API.CustomCode;