From e09cfed52a838a314abb38d622495507cf07941f Mon Sep 17 00:00:00 2001 From: "Theunis J. Botha" Date: Wed, 21 Jun 2017 12:22:39 +0200 Subject: [PATCH] loading now much more streamlined --- src/game-lib-a-2-utils.js | 36 ++++++++++++++++++++++++++++++++++ src/game-lib-system-storage.js | 3 ++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/game-lib-a-2-utils.js b/src/game-lib-a-2-utils.js index cd1643b..37a5d2c 100644 --- a/src/game-lib-a-2-utils.js +++ b/src/game-lib-a-2-utils.js @@ -557,3 +557,39 @@ GameLib.Utils.MovingAverage = function(period) { return(sum/n); } }; + +GameLib.Utils.Intersect = function (a, b) { + + var t; + + /** + * Loop over shortest array + */ + if (b.length > a.length) { + t = b; + b = a; + a = t; + } + + return a.filter( + /** + * Check if exists + * @param e + * @returns {boolean} + */ + function (e) { + return (b.indexOf(e) > -1); + } + ).filter( + /** + * Remove Duplicates + * @param e + * @param i + * @param c + * @returns {boolean} + */ + function (e, i, c) { + return c.indexOf(e) === i; + } + ); +}; \ No newline at end of file diff --git a/src/game-lib-system-storage.js b/src/game-lib-system-storage.js index 6659d2e..c9bc7fd 100644 --- a/src/game-lib-system-storage.js +++ b/src/game-lib-system-storage.js @@ -161,7 +161,8 @@ GameLib.System.Storage.prototype.load = function(data) { this.publish( GameLib.Event.COMPONENT_LOADED, { - response : object + response : object, + includeDependencies : data.includeDependencies } ) }