2017-01-13 16:19:51 +01:00
|
|
|
/**
|
2017-06-16 15:49:53 +02:00
|
|
|
* Custom Code Component
|
|
|
|
* @param id
|
|
|
|
* @param name
|
2017-08-24 22:20:40 +02:00
|
|
|
* @param eventId
|
2017-06-16 15:49:53 +02:00
|
|
|
* @param code
|
2017-08-24 22:20:40 +02:00
|
|
|
* @param parentEntity
|
2017-01-13 16:19:51 +01:00
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.CustomCode = function (
|
2017-08-24 22:20:40 +02:00
|
|
|
id,
|
|
|
|
name,
|
|
|
|
eventId,
|
|
|
|
code,
|
|
|
|
parentEntity
|
2017-01-13 16:19:51 +01:00
|
|
|
) {
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
|
|
id = GameLib.Utils.RandomId();
|
|
|
|
}
|
|
|
|
this.id = id;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
|
|
|
name = 'CustomCode (' + this.id + ')';
|
|
|
|
}
|
|
|
|
this.name = name;
|
|
|
|
|
2017-08-24 22:20:40 +02:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(eventId)) {
|
2017-08-25 16:52:32 +02:00
|
|
|
eventId = 42;
|
2017-08-24 22:20:40 +02:00
|
|
|
}
|
|
|
|
this.eventId = eventId;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(code)) {
|
|
|
|
code = 'return null;';
|
|
|
|
}
|
|
|
|
this.code = code;
|
|
|
|
|
2017-06-16 15:49:53 +02:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
|
|
|
parentEntity = null;
|
|
|
|
}
|
|
|
|
this.parentEntity = parentEntity;
|
|
|
|
|
2017-01-13 16:19:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
GameLib.D3.API.CustomCode.prototype = Object.create(GameLib.Component.prototype);
|
|
|
|
GameLib.D3.API.CustomCode.prototype.constructor = GameLib.D3.API.CustomCode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object to GameLib.D3.API.CustomCode
|
|
|
|
* @param objectComponent
|
|
|
|
* @returns {GameLib.D3.API.CustomCode}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2017-06-14 14:21:57 +02:00
|
|
|
GameLib.D3.API.CustomCode.FromObject = function(objectComponent) {
|
2017-01-13 16:19:51 +01:00
|
|
|
return new GameLib.D3.API.CustomCode(
|
|
|
|
objectComponent.id,
|
|
|
|
objectComponent.name,
|
2017-08-24 22:20:40 +02:00
|
|
|
objectComponent.eventId,
|
2017-01-13 16:19:51 +01:00
|
|
|
objectComponent.code,
|
2017-08-24 22:20:40 +02:00
|
|
|
objectComponent.parentEntity
|
2017-01-13 16:19:51 +01:00
|
|
|
);
|
|
|
|
};
|