mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-18 07:18:38 +02:00
Convert crime to new work model
This commit is contained in:
21
src/PersonObjects/Player/PlayerObjectWorkMethods.ts
Normal file
21
src/PersonObjects/Player/PlayerObjectWorkMethods.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Work } from "../../Work/Work";
|
||||
import { IPlayer } from "../IPlayer";
|
||||
|
||||
export function start(this: IPlayer, w: Work): void {
|
||||
if (this.currentWork !== null) {
|
||||
this.currentWork.finish(this, true);
|
||||
}
|
||||
this.currentWork = w;
|
||||
}
|
||||
export function process(this: IPlayer, cycles = 1): void {
|
||||
if (this.currentWork === null) return;
|
||||
const finished = this.currentWork.process(this, cycles);
|
||||
if (finished) {
|
||||
this.finishNEWWork(false);
|
||||
}
|
||||
}
|
||||
export function finish(this: IPlayer, cancelled: boolean): void {
|
||||
if (this.currentWork === null) return;
|
||||
this.currentWork.finish(this, cancelled);
|
||||
this.currentWork = null;
|
||||
}
|
||||
Reference in New Issue
Block a user