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

84 lines
1.9 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
2017-01-20 13:40:27 +01:00
* @param domElement
* @param domStats
2017-01-12 04:44:01 +01:00
* @param parentEntity
* @constructor
*/
GameLib.API.System = function (
id,
name,
systemType,
entityManager,
2017-01-20 13:40:27 +01:00
domElement,
domStats,
2017-01-12 04:44:01 +01:00
parentEntity
) {
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_SYSTEM,
2017-01-20 13:40:27 +01:00
{
'entityManager' : GameLib.EntityManager,
'domElement' : GameLib.DomElement,
'domStats' : GameLib.DomElement
},
2017-01-12 04:44:01 +01:00
null,
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-20 13:40:27 +01:00
if (GameLib.Utils.UndefinedOrNull(domElement)){
domElement = null;
}
this.domElement = domElement;
if (GameLib.Utils.UndefinedOrNull(domStats)){
domStats = null;
}
this.domStats = domStats;
2017-01-12 04:44:01 +01:00
};
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,
2017-01-20 13:40:27 +01:00
objectComponent.domElement,
objectComponent.domStats,
2017-01-12 04:44:01 +01:00
objectComponent.parentEntity
);
};