Files
node-metaverse/dist/classes/Inventory.js

59 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-12-13 15:23:50 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const UUID_1 = require("./UUID");
2017-12-19 23:43:00 +00:00
const InventoryFolder_1 = require("./InventoryFolder");
2018-10-10 10:36:12 +01:00
const __1 = require("..");
2017-12-13 15:23:50 +00:00
class Inventory {
constructor(clientEvents, agent) {
2017-12-13 15:23:50 +00:00
this.main = {
2017-12-19 23:43:00 +00:00
skeleton: {}
2017-12-13 15:23:50 +00:00
};
this.library = {
2017-12-19 23:43:00 +00:00
skeleton: {}
2017-12-13 15:23:50 +00:00
};
this.agent = agent;
2017-12-13 15:23:50 +00:00
this.clientEvents = clientEvents;
}
2017-12-19 23:43:00 +00:00
getRootFolderLibrary() {
if (this.library.root === undefined) {
return new InventoryFolder_1.InventoryFolder(this.library, this.agent);
2017-12-19 23:43:00 +00:00
}
const uuidStr = this.library.root.toString();
if (this.library.skeleton[uuidStr]) {
return this.library.skeleton[uuidStr];
}
else {
return new InventoryFolder_1.InventoryFolder(this.library, this.agent);
2017-12-19 23:43:00 +00:00
}
}
getRootFolderMain() {
if (this.main.root === undefined) {
return new InventoryFolder_1.InventoryFolder(this.main, this.agent);
2017-12-19 23:43:00 +00:00
}
const uuidStr = this.main.root.toString();
if (this.main.skeleton[uuidStr]) {
return this.main.skeleton[uuidStr];
}
else {
return new InventoryFolder_1.InventoryFolder(this.main, this.agent);
2017-12-19 23:43:00 +00:00
}
}
findFolderForType(type) {
if (this.main.root === undefined) {
return UUID_1.UUID.zero();
}
2018-10-10 10:36:12 +01:00
if (type === __1.AssetType.Folder) {
return this.main.root;
}
let found = UUID_1.UUID.zero();
Object.keys(this.main.skeleton).forEach((fUUID) => {
const folder = this.main.skeleton[fUUID];
if (folder.typeDefault === type) {
found = folder.folderID;
}
});
return found;
}
2017-12-13 15:23:50 +00:00
}
exports.Inventory = Inventory;
//# sourceMappingURL=Inventory.js.map