// areAnscestorsOpen.js
(function() {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Tangible.prototype;
/**
* Checks to see if this asset's containing parent(s)
* is open. 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#areAnscestorsOpen
* @returns {Boolean}
*/
p.areAnscestorsOpen = function Tangible_areAnscestorsOpen()
{
var parent = this.getPlaceAsset();
var parentOpen = true;
var anscestorsOpen = true;
if( parent
&& "undefined" !== typeof parent.is.closed
&& "undefined" !== typeof parent.areAnscestorsOpen )
{
parentOpen = ( false === parent.is.closed );
anscestorsOpen = parent.areAnscestorsOpen();
}
if (parentOpen && anscestorsOpen)
{
return true;
}
else
{
return false;
}
//return parentOpen
}
}());