Files
galvanic-corrosion-rewrite/src/server/instances/base.ts

47 lines
1.1 KiB
TypeScript

import Logging from "@proxnet/undead-logging";
import { ServerContentBase } from "../ContentBase.ts";
import { type Instance } from "./Instance.ts";
const log = new Logging("Instances");
export class InstanceManager extends ServerContentBase {
#instances: Set<Instance> = new Set();
clearEmptyInstances() {
log.i(`Starting instance purge\n Before: ${
this.#instances.size
} instances, ${
this.#instances.values().reduce((prev, current) => prev + current.getPlayers().length, 0)
} players`);
return new Promise(() => {
for (const inst of this.#instances) {
if (inst.getPlayers().length === 0) this.deleteInstance(inst);
}
log.i(`Instance purge complete\n After: ${
this.#instances.size
} instances, ${
this.#instances.values().reduce((prev, current) => prev + current.getPlayers().length, 0)
} players`);
});
}
getAllInstances() {
}
registerInstance(inst: Instance) {
}
getInstance(id: number) {
}
deleteInstance(inst: Instance) {
}
}