r3-legacy/src/game-lib-api-system.js

65 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-01-12 04:44:01 +01:00
/**
* This component renders a scene
* @param id String
* @param name String
* @param systemType
* @param entityManager
* @param parentEntity
* @constructor
*/
GameLib.API.System = function (
id,
name,
systemType,
entityManager,
parentEntity
) {
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_SYSTEM,
2017-01-20 13:40:27 +01:00
{
2017-05-22 11:34:18 +02:00
'entityManager' : GameLib.EntityManager
2017-01-20 13:40:27 +01:00
},
2017-01-12 04:44:01 +01:00
parentEntity
);
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = "System (" + this.id + ")";
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(systemType)) {
systemType = GameLib.System.SYSTEM_TYPE_RENDER;
}
this.systemType = systemType;
if (GameLib.Utils.UndefinedOrNull(entityManager)) {
entityManager = null;
}
this.entityManager = entityManager;
};
2017-01-19 17:50:11 +01:00
GameLib.API.System.prototype = Object.create(GameLib.Component.prototype);
GameLib.API.System.prototype.constructor = GameLib.API.System;
2017-01-12 04:44:01 +01:00
/**
* Object to GameLib.D3.API.System
* @param objectComponent
* @constructor
*/
GameLib.API.System.FromObjectComponent = function(objectComponent) {
return new GameLib.API.System(
objectComponent.id,
objectComponent.name,
objectComponent.systemType,
objectComponent.entityManager,
objectComponent.parentEntity
);
};