2022-07-07 08:00:23 +02:00
|
|
|
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) {
|
2022-07-14 23:43:08 +02:00
|
|
|
this.finishWork(false);
|
2022-07-07 08:00:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
export function finish(this: IPlayer, cancelled: boolean): void {
|
|
|
|
if (this.currentWork === null) return;
|
|
|
|
this.currentWork.finish(this, cancelled);
|
|
|
|
this.currentWork = null;
|
2022-07-22 00:27:23 +02:00
|
|
|
this.focus = false;
|
2022-07-07 08:00:23 +02:00
|
|
|
}
|