// Drainable_Is.js
(function () {
/*global adventurejs A*/
"use strict";
/**
* @ajspath adventurejs.Atom.StateManager.Asset_Is.Tangible_Is.Drainable_Is
* @augments adventurejs.Tangible_Is
* @class adventurejs.Drainable_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>Drainable_Is.js</strong> handles is.state management for
* {@link adventurejs.Drainable|Drainable Assets}.
**/
class Drainable_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 = "Drainable_Is";
this._plugged = false;
return this;
}
/**
* <code>plugged</code> indicates whether the object is plugged
* via the verb plug. The Drainable class handles plugged
* distinctly from other classes, because a Drainable instance
* may be set so that substances drain out of it, or it may be
* linked to a separate asset that acts as its drain. This
* sounds confusing, so here's an example: imagine an author
* wants to make a sink that users can plug and unplug with a
* stopper. Fair enough, and we can set that sink.is.plugged.
* Now, imagine an author wants players to be able to interact
* with the sink and the drain as distinct objects; in this
* case the author would link a Drain asset to the Sink asset.
* In the latter scenario, checking plugged on the sink
* would actually return the plugged value of the drain.
* @var {Boolean} adventurejs.Drainable#is!plugged
* @default false
*/
get plugged() {
let parent = this.parent;
if (parent.registered_parts?.Drain) {
let drain = this.game.getAsset(parent.registered_parts.Drain);
return drain.is.plugged;
} else return this._plugged;
}
set plugged(value) {
let parent = this.parent;
if (parent.registered_parts?.Drain) {
let drain = this.game.getAsset(parent.registered_parts.Drain);
drain.is.plugged = value;
} else this._plugged = value;
}
}
adventurejs.Drainable_Is = Drainable_Is;
})();