// onMoveThatToThis.js
(function () {
/* global adventurejs A */
var p = adventurejs.Tangible.prototype;
/**
* Called when another asset is added to this.
* Provides opportunities to override default behavior
* through the use of
* <a href="/doc/Scripting_VerbReactions.html">verb reactions</a>
* doMoveThisToThat and doMoveThatToThis.
* @memberOf adventurejs.Tangible
* @method adventurejs.Tangible#onMoveThatToThis
* @param {Object} asset
* @param {String} where
* @returns {*}
*/
p.onMoveThatToThis = function Tangible_onMoveThatToThis(asset, aspect) {
if ("string" === typeof asset) asset = this.game.getAsset(asset);
if (!asset) return;
this.game.log(
"L1457",
"log",
"high",
`[onMoveThatToThis.js] move ${asset.id} ${aspect} ${this.id} `,
"Tangible"
);
var results;
//
if ("string" !== typeof aspect) {
aspect = this.default_aspect;
}
// check receiving asset for verb hook
results = this.doVerbAction({
action: "doMoveThatToThis",
asset2: asset.name,
params: {
preposition: aspect,
},
type: "VerbReaction",
});
if ("undefined" !== typeof results) return results;
// check asset to be placed for verb hook
results = asset.doVerbAction({
action: "doMoveThisToThat",
asset2: this.name,
type: "VerbReaction",
});
if ("undefined" !== typeof results) return results;
// reset asset's position
asset.position = { x: 0, y: 0, z: 0 };
// set asset's new location to this
asset.setPlace(aspect, this.id);
}; // onMoveThatToThis.js
})();