From e2c307ec78b6082143625fc88e08cbc0b04d34b4 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Fri, 27 Oct 2017 11:00:11 +0200 Subject: [PATCH] update getDependencies --- src/game-lib-a-component-a.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/game-lib-a-component-a.js b/src/game-lib-a-component-a.js index bd02d07..18e364d 100644 --- a/src/game-lib-a-component-a.js +++ b/src/game-lib-a-component-a.js @@ -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() { var dependencies = []; @@ -113,26 +117,24 @@ GameLib.Component.prototype.getDependencies = function() { } if (this[property] instanceof Array) { - this[property].map(function(arrayProperty){ + this[property].map( + function(arrayProperty) { - if (typeof arrayProperty === 'string') { - GameLib.Utils.PushUnique(dependencies, arrayProperty); - } + if (typeof arrayProperty === 'string') { + GameLib.Utils.PushUnique(dependencies, arrayProperty); + } - if (arrayProperty && - typeof arrayProperty === 'object' && - arrayProperty.hasOwnProperty('loaded') && - arrayProperty.loaded === false - ) { - GameLib.Utils.PushUnique(dependencies, arrayProperty.id); + if (arrayProperty && + arrayProperty instanceof GameLib.Component + ) { + GameLib.Utils.PushUnique(dependencies, arrayProperty.id); + } } - }); + ); } if (this[property] && - typeof this[property] === 'object' && - this[property].hasOwnProperty('loaded') && - this[property].loaded === false + this[property] instanceof GameLib.Component ) { GameLib.Utils.PushUnique(dependencies, this[property].id); }