// hasAnyPartContainingAnySubstance.js
(function () {
/* global adventurejs A */
var p = adventurejs.Tangible.prototype;
/**
* Check whether this asset has a registered part that
* contains any substance.
* @memberOf adventurejs.Tangible
* @method adventurejs.Tangible#hasAnyPartContainingAnySubstance
* @returns {object|null}
*/
p.hasAnyPartContainingAnySubstance =
function Tangible_hasAnyPartContainingAnySubstance() {
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.containsAnySubstance()) 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.containsAnySubstance()) return true;
}
}
}
return false;
}; // hasAnyPartContainingAnySubstance.js
})();