Pre-release
AdventureJS Docs Downloads Bundler Devlog
Score: 0 Moves: 0
// onNestThatToThis.js
(function () {
  /* global AdventureJS A */
  var p = AdventureJS.Assets.Entity.prototype;
  /**
   * Called when a player asset is nested to this.
   * Provides an opportunity to override default behavior
   * through the use of
   * <a href="/doc/Verbs_ReactionHooks.html">verb reactions</a>
   * doNestThatToThis.
   * @memberOf AdventureJS.Assets.Entity
   * @method AdventureJS.Assets.Entity#onNestThatToThis
   * @param {Object} asset A character asset.
   * @returns {Boolean}
   */
  p.onNestThatToThis = function Entity_onNestThatToThis(asset, preposition) {
    if ("string" === typeof asset) asset = this.game.getAsset(asset);
    if (!asset) return;
    this.game.log(
      "L1484",
      "log",
      "high",
      `[onNestThatToThis.js] nest ${asset.id} to ${this.id}`,
      "Entity"
    );
    var results;
    var msg = "";

    let destroyed = asset.is.destroyed;

    // Simple vehicles go into character inventory.

    if (this.isDOV("ride") && !this.isWithin(asset)) {
      // move this from its parent
      results = this.onMoveThisFromThat(this.getPlaceAsset());
      if ("undefined" !== typeof results) return results;

      // move this into character inventory
      results = this.onMoveThisToThat("in", asset);
      if ("undefined" !== typeof results) return results;
    }

    // allow for author to add custom interactions per-object
    results = this.doVerbAction({
      action: "doNestThatToThis",
      target: asset,
      type: "VerbReaction",
    });
    if ("undefined" !== typeof results) return results;

    if (!destroyed && asset.is.destroyed) return;

    return;
  };
})();