@runejs/filestore
Version:
Tools for managing the RuneJS filestore.
73 lines (72 loc) • 2.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigStore = exports.getConfigId = exports.configIdMap = void 0;
const configs_1 = require("./configs");
/**
* A map of unique config keys to file/archive ids within the config store.
*/
exports.configIdMap = {
character: 3,
objects: 6,
npcs: 9,
items: 10,
animations: 12,
graphics: 13,
varbits: 14,
};
/**
* Finds the corresponding string config key for the given numeric id.
* @param config The numeric config file/archive id to find the name of.
*/
const getConfigId = (config) => {
const ids = Object.keys(exports.configIdMap);
for (const id of ids) {
if (exports.configIdMap[id] === config) {
return id;
}
}
return null;
};
exports.getConfigId = getConfigId;
/**
* Contains various configuration related Archives.
*/
class ConfigStore {
fileStore;
/**
* A Store used to access the Item Archive, containing details about every game item.
*/
itemStore;
/**
* A Store used to access the Npc Archive, containing details about every game npc.
*/
npcStore;
/**
* A Store used to access the Object Archive, containing details about every game object.
*/
objectStore;
/**
* A Store used to access the Varbit Archive, containing details about every game varbit.
*/
varbitStore;
/**
* The configuration file/archive index.
*/
configIndex;
constructor(fileStore) {
this.fileStore = fileStore;
this.configIndex = fileStore.getIndex('configs');
this.itemStore = new configs_1.ItemStore(this);
this.npcStore = new configs_1.NpcStore(this);
this.objectStore = new configs_1.ObjectStore(this);
this.varbitStore = new configs_1.VarbitStore(this);
}
getArchive(inputConfigId) {
let configId = inputConfigId;
if (typeof configId !== 'number') {
configId = exports.configIdMap[configId];
}
return this.configIndex.getArchive(configId);
}
}
exports.ConfigStore = ConfigStore;