update getDependencies

beta.r3js.org
-=yb4f310 2017-10-27 11:00:11 +02:00
parent 84a98df77a
commit e2c307ec78
1 changed files with 16 additions and 14 deletions

View File

@ -97,6 +97,10 @@ GameLib.Component.prototype.createInstance = function() {
}; };
/**
* Dependencies are everything which is either a string or an object with an id which is linked to this object
* @returns {Array}
*/
GameLib.Component.prototype.getDependencies = function() { GameLib.Component.prototype.getDependencies = function() {
var dependencies = []; var dependencies = [];
@ -113,26 +117,24 @@ GameLib.Component.prototype.getDependencies = function() {
} }
if (this[property] instanceof Array) { if (this[property] instanceof Array) {
this[property].map(function(arrayProperty){ this[property].map(
function(arrayProperty) {
if (typeof arrayProperty === 'string') { if (typeof arrayProperty === 'string') {
GameLib.Utils.PushUnique(dependencies, arrayProperty); GameLib.Utils.PushUnique(dependencies, arrayProperty);
} }
if (arrayProperty && if (arrayProperty &&
typeof arrayProperty === 'object' && arrayProperty instanceof GameLib.Component
arrayProperty.hasOwnProperty('loaded') && ) {
arrayProperty.loaded === false GameLib.Utils.PushUnique(dependencies, arrayProperty.id);
) { }
GameLib.Utils.PushUnique(dependencies, arrayProperty.id);
} }
}); );
} }
if (this[property] && if (this[property] &&
typeof this[property] === 'object' && this[property] instanceof GameLib.Component
this[property].hasOwnProperty('loaded') &&
this[property].loaded === false
) { ) {
GameLib.Utils.PushUnique(dependencies, this[property].id); GameLib.Utils.PushUnique(dependencies, this[property].id);
} }