// areAnscestorsClosed.js
(function () {
/*global adventurejs A*/
var p = adventurejs.Tangible.prototype;
/**
* Checks to see if this asset's containing parent(s) is closed.
* Takes into account nesting doll
* situations and looks all the way up the chain.
* Useful for determining whether a player can interact
* with a nested object.
* @memberOf adventurejs.Tangible
* @method adventurejs.Tangible#areAnscestorsClosed
* @returns {Boolean}
*/
p.areAnscestorsClosed = function Tangible_areAnscestorsClosed() {
//console.warn( 'areAnscestorsClosed this',this.id);
var parent = this.getPlaceAsset();
//console.warn( '- areAnscestorsClosed parent',parent.id);
var parentClosed = false;
var anscestorsClosed = false;
if (
parent &&
"undefined" !== typeof parent.is.closed &&
"undefined" !== typeof parent.areAnscestorsClosed
) {
parentClosed = parent.isDOV("close") && parent.is.closed;
//console.warn('--',parent.id,'.parentClosed',parentClosed );
anscestorsClosed = parent.areAnscestorsClosed();
//console.warn('--',parent.id,'.anscestorsClosed',anscestorsClosed );
}
//console.warn('-',parent.id,'says parentClosed',parentClosed,'anscestorsClosed',anscestorsClosed);
if (parentClosed || anscestorsClosed) {
return true;
}
return false;
};
})();