Files
Construct-CN/scripts/classes/StructureCollection.js
T
2025-03-11 02:13:16 -07:00

31 lines
674 B
JavaScript

import { Structure } from './Structure';
class StructureCollection {
#structures;
constructor() {
this.#structures = {};
}
add(name) {
const structure = new Structure(name);
this.#structures[name] = structure;
return structure;
}
get(name) {
const structure = this.#structures[name];
if (!structure) {
throw new Error(`Structure ${name} not found.`);
}
return structure;
}
remove(name) {
const struct = this.get(name);
struct.remove();
delete this.#structures[name];
}
}
export const structureCollection = new StructureCollection();