mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-10-23 18:23:15 +02:00
e578bd7681
Use PlayerObject instead when referring to the type of "The Player."
23 lines
670 B
TypeScript
23 lines
670 B
TypeScript
import { Work } from "../../Work/Work";
|
|
import { PlayerObject } from "./PlayerObject";
|
|
|
|
export function startWork(this: PlayerObject, w: Work): 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): void {
|
|
if (this.currentWork === null) return;
|
|
this.currentWork.finish(cancelled);
|
|
this.currentWork = null;
|
|
this.focus = false;
|
|
}
|