// Exit_Is.js
(function () {
/*global adventurejs A*/
"use strict";
/**
* @ajspath adventurejs.Atom.StateManager.Asset_Is.Tangible_Is.Exit_Is
* @augments adventurejs.Tangible_Is
* @class adventurejs.Exit_Is
* @ajsnavheading StateClasses
* @param {String} game_name Name of top level game instance that is scoped to window.
* @param {String} name Instance name.
* @summary A container for state variables.
* @classdesc
* <p>
* <strong>Exit_Is.js</strong> handles is.state management for
* {@link adventurejs.Exit|Exit Assets}.
**/
class Exit_Is extends adventurejs.Tangible_Is {
constructor(name = "is", game_name, parent_id) {
// Call the constructor of the parent class
super(name, game_name, parent_id);
this.class = "Exit_Is";
this._used = false;
this.exit = true;
return this;
}
set used(value) {
this._used = value;
this.setLinkedApertureState("used", value);
}
get used() {
return this._used;
}
/**
* The Exit class has no intrinsic open/closed states, and
* instead looks for a linked {@link adventurejs.Aperture} asset.
* <code>closed</code> is a paired property. Setting open = true
* also sets close = false, and if this exit's aperture has a linked
* asset, open and close are set for that asset as well.
* @var {Boolean} adventurejs.Exit#is!closed
* @default false
*/
get closed() {
return this.getLinkedApertureState("closed");
}
// set closed(value) {
// this.setLinkedApertureState("closed", value);
// }
/**
* The Exit class has no intrinsic locked/unlocked states, and
* instead looks for a linked {@link adventurejs.Aperture} asset.
* <code>locked</code> is a paired property. Setting locked = true
* also sets unlocked = false, and if this exit's aperture has a linked
* asset, locked and unlocked are set for that asset as well.
* @var {Boolean} adventurejs.Exit#is!locked
* @default false
*/
get locked() {
return this.getLinkedApertureState("locked");
}
// set locked(value) {
// this.setLinkedApertureState("locked", value);
// }
/**
* The Exit class has no intrinsic sealed/unsealed states, and
* instead looks for a linked {@link adventurejs.Aperture} asset.
* <code>sealed</code> is a paired property. Setting sealed = true
* also sets unsealed = false, and if this exit's aperture has a linked
* asset, sealed and unsealed are set for that asset as well.
* @var {Boolean} adventurejs.Exit#is!sealed
* @default false
*/
get sealed() {
return this.getLinkedApertureState("sealed");
}
// set sealed(value) {
// this.setLinkedApertureState("sealed", value);
// }
/**
* The Exit class is a simple class used primarily to facilitate
* travel between two locations. It's not treated as a physical thing
* and doesn't have any of the intrinsic states that you would
* associate with a door. If an exit needs a physical manifestation,
* it can be paired with a linked {@link adventurejs.Aperture} asset.
* It's the Aperture that contains all the state information. In order
* to support queries like exit.is.closed we redirect the getter/setter
* to the specified property on the linked Aperture.
* @var {Boolean} adventurejs.Exit#is!setLinkedApertureState
* @param {String} property
* @param {*} value
*/
setLinkedApertureState(property, value) {
var parent = this.parent;
if (parent && parent.aperture) {
var aperture = this.game.getAsset(parent.aperture);
if (aperture && aperture[this.name]) {
aperture[this.name][property] = value;
}
}
}
/**
* The Exit class is a simple class used primarily to facilitate
* travel between two locaions. It's not treated as a physical thing
* and doesn't have any of the intrinsic states that you would
* associate with a door. If an exit needs a physical manifestation,
* it can be paired with a linked {@link adventurejs.Aperture} asset.
* It's the Aperture that contains all the state information. In order
* to support queries like exit.is.closed we redirect the getter/setter
* to the specified property on the linked Aperture.
* @var {Boolean} adventurejs.Exit#is!getLinkedApertureState
* @param {String} property
*/
getLinkedApertureState(property) {
var parent = this.parent;
if (!parent || !parent.aperture) {
return null;
}
var aperture = this.game.getAsset(parent.aperture);
if (!aperture) {
return null;
}
return aperture.is[property];
}
}
adventurejs.Exit_Is = Exit_Is;
})();