Turn.every

This commit is contained in:
Tony Garnock-Jones 2022-01-20 20:48:30 +01:00
parent c20cab0bba
commit 83cc561cce
1 changed files with 15 additions and 0 deletions

View File

@ -450,6 +450,21 @@ export class Turn {
if (a !== null) this.enqueue(ref.relay, () => ref.target.message?.(assertion));
}
every(periodMilliseconds: number, a: LocalAction): any {
const facet = this.activeFacet;
facet.preventInertCheck();
let handle: any = setInterval(() => {
facet.turn(a);
}, periodMilliseconds);
facet.onStop(() => {
if (handle !== null) {
clearInterval(handle);
handle = null;
}
});
return handle;
}
after(delayMilliseconds: number, a: LocalAction): any {
const facet = this.activeFacet;
const release = facet.preventInertCheck();