// destroyAsset.js
(function () {
/* global AdventureJS A */
var p = AdventureJS.Game.prototype;
/**
* <strong>destroyAsset()</strong> removes an asset from the game world.
* @method AdventureJS.Game#destroyAsset
* @memberOf AdventureJS.Game
* @param {Object} asset The asset to be removed.
*/
p.destroyAsset = p.destroy = function Game_destroyAsset(asset, del = false) {
if ("string" === typeof asset) asset = this.game.getAsset(asset);
if (!asset) return false;
this.game.log(
"L1713",
"log",
"high",
`[Game.js] destroyAsset ${asset.id}`,
"Game"
);
let results;
if (asset.destroy) {
results = asset.destroy();
if ("undefined" !== typeof results) return results;
}
asset.is.destroyed = true;
asset.is.extant = false;
if ("undefined" === typeof this.to_be_destroyed[asset.id]) {
this.to_be_destroyed[asset.id] = { id: asset.id, del: del };
}
return true;
};
})();