// destroyAssets.js
(function () {
/* global AdventureJS A */
var p = AdventureJS.Game.prototype;
/**
* Destroy assets added to to_be_destroyed by destroyAsset().
* @method AdventureJS.Game#destroyAssets
* @memberOf AdventureJS.Game
*/
p.destroyAssets = function Game_destroyAssets() {
this.game.log("L1714", "log", "high", `[Game.js] destroyAssets`, "Game");
for (let prop in this.to_be_destroyed) {
const deferred = this.to_be_destroyed[prop];
let asset = this.game.getAsset(deferred.id);
if (!asset) continue;
this.game.log(
"L1715",
"log",
"high",
`[Game.js] ↳ destroy ${asset.id}`,
"Game"
);
// clear intervals
if ("undefined" !== typeof this.game.world._intervals[asset.id]) {
delete this.world._intervals[asset.id];
}
if (asset.setPlace) {
asset.setPlace();
}
let stack = false;
if (asset.stack) {
asset.stack.destroy();
stack = true;
}
// if we received del=true or it's a stack, delete it
if (deferred.del || stack) {
this.game.removeAssetFromLookup(asset);
delete this.game.world[asset.id];
}
delete this.game.to_be_destroyed[deferred.id];
asset = null;
}
};
})();