Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// canAnyPartContainSubstances.js
(function () {
  /* global adventurejs A */
  var p = adventurejs.Tangible.prototype;
  /**
   * Check whether this asset has a registered part that
   * can contain a substance.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#canAnyPartContainSubstances
   * @returns {boolean}
   */
  p.canAnyPartContainSubstances =
    function Tangible_canAnyPartContainSubstances() {
      const parent = this.linked_parent
        ? this.game.getAsset(this.linked_parent)
        : this;

      for (var prop in parent.linked_components) {
        if (
          !Object.prototype.hasOwnProperty.call(parent.linked_components, prop)
        )
          continue;
        if ("string" === typeof parent.linked_components[prop]) {
          let asset = this.game.getAsset(parent.linked_components[prop]);
          if (!asset) continue;
          if (asset.canContainSubstances()) return true;
        } else if (Array.isArray(parent.linked_components[prop])) {
          for (let i = 0; i < parent.linked_components[prop].length; i++) {
            let asset = this.game.getAsset(parent.linked_components[prop][i]);
            if (!asset) continue;
            if (asset.canContainSubstances()) return true;
          }
        }
      }

      return null;
    }; // canAnyPartContainSubstances.js
})();