Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// onDeactivate.js
(function () {
  /* global adventurejs A */
  var p = adventurejs.Tangible.prototype;
  /**
   * Called when an asset is activated as a result of verb
   * <code>turnOn</code> or by other verbs or circumstances.
   * Provides an opportunity to override default behavior
   * through the use of the <code>doActivate</code>
   * <a href="/doc/Verbs_ReactionHooks.html">verb reaction</a>.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#onDeactivate
   * @param {Object} asset
   * @param {String} where
   * @returns {*}
   */
  p.onDeactivate = function Tangible_onDeactivate(asset) {
    if ("string" === typeof asset) asset = this.game.getAsset(asset);
    if (!asset) return;
    this.game.log(
      "L1580",
      "log",
      "high",
      `[onDeactivate.js] deactivate ${this.id}`,
      "Tangible"
    );
    var results;

    // check receiving asset for verb hook
    results = this.doVerbAction({
      action: "doActivate",
      type: "VerbReaction",
    });
    if ("undefined" !== typeof results) return results;

    // state change
    this.is.active = false;
  }; // onDeactivate.js
})();