mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 04:17:05 +02:00
24 lines
745 B
TypeScript
24 lines
745 B
TypeScript
import type { PlayerBaseWork } from "../../Work/Work";
|
|
|
|
import type { PlayerObject } from "./PlayerObject";
|
|
|
|
export function startWork(this: PlayerObject, w: PlayerBaseWork): void {
|
|
if (this.currentWork !== null) {
|
|
this.currentWork.finish(true);
|
|
}
|
|
this.currentWork = w;
|
|
}
|
|
export function processWork(this: PlayerObject, cycles = 1): void {
|
|
if (this.currentWork === null) return;
|
|
const finished = this.currentWork.process(cycles);
|
|
if (finished) {
|
|
this.finishWork(false);
|
|
}
|
|
}
|
|
export function finishWork(this: PlayerObject, cancelled: boolean, suppressDialog?: boolean): void {
|
|
if (this.currentWork === null) return;
|
|
this.currentWork.finish(cancelled, !!suppressDialog);
|
|
this.currentWork = null;
|
|
this.focus = false;
|
|
}
|