Tighten
This commit is contained in:
parent
ba2b2edfc3
commit
ecef864793
8
actor.ts
8
actor.ts
|
@ -71,7 +71,8 @@ export class Turn {
|
||||||
static for(actor: Actor, f: LocalAction): void {
|
static for(actor: Actor, f: LocalAction): void {
|
||||||
const t = new Turn(actor);
|
const t = new Turn(actor);
|
||||||
f(t);
|
f(t);
|
||||||
t.complete();
|
t.queues.forEach((q, a) => a.execute(() => q.forEach(f => Turn.for(a, f))));
|
||||||
|
t.tasks.length && queueMicrotask(() => t.tasks.forEach(f => Turn.for(actor, f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private constructor(actor: Actor) {
|
private constructor(actor: Actor) {
|
||||||
|
@ -135,9 +136,4 @@ export class Turn {
|
||||||
enqueue(actor: Actor, a: LocalAction): void {
|
enqueue(actor: Actor, a: LocalAction): void {
|
||||||
this.queues.get(actor)?.push(a) ?? this.queues.set(actor, [a]);
|
this.queues.get(actor)?.push(a) ?? this.queues.set(actor, [a]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private complete(): void {
|
|
||||||
this.queues.forEach((q, a) => a.execute(() => q.forEach(f => Turn.for(a, f))));
|
|
||||||
this.tasks.length && queueMicrotask(() => this.tasks.forEach(f => Turn.for(this.actor, f)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue