// 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/BasicVerbs_ReactionHooks.html">verb reactions</a>
* doNestThatToThis.
* @memberOf AdventureJS.Assets.Entity
* @method AdventureJS.Assets.Entity#onNestThatToThis
* @param {Object} subject A character subject.
* @returns {Boolean}
*/
p.onNestThatToThis = function Entity_onNestThatToThis(subject, preposition) {
if ("string" === typeof subject) subject = this.game.getAsset(subject);
if (!subject) return;
this.game.log(
"L1484",
"log",
"high",
`[onNestThatToThis.js] nest ${subject.id} to ${this.id}`,
"Entity"
);
var results;
var msg = "";
let destroyed = subject.is.destroyed;
// Simple vehicles go into character inventory.
if (this.isDOV("ride") && !this.isWithin(subject)) {
// 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", subject);
if ("undefined" !== typeof results) return results;
}
// allow for author to add custom interactions per-object
results = this.doVerbAction({
action: "doNestThatToThis",
target: subject,
type: "VerbReaction",
});
if ("undefined" !== typeof results) return results;
if (subject.id === this.game.world._player) {
results = this.doVerbAction({
action: "doPlayerEnter",
target: subject,
params: {},
type: "VerbReaction",
});
if ("undefined" !== typeof results) return results;
}
if (!destroyed && subject.is.destroyed) return;
return;
};
})();