Actions::serial

This commit is contained in:
cha0s 2019-06-07 00:14:16 -05:00
parent 1bd7bc41a3
commit 9239d5b2e6
2 changed files with 23 additions and 0 deletions

View File

@ -30,6 +30,10 @@ export class Globals {
return min + (floor ? Math.floor(mag) : mag); return min + (floor ? Math.floor(mag) : mag);
} }
serial(actions, context) {
return actions.serial(context);
}
testing() { testing() {
return null; return null;
} }

View File

@ -114,4 +114,23 @@ export class Actions extends decorate(Traversals) {
} }
} }
serial(context) {
// Do a "dry" tick.
this.tick(context, 0);
// If it's pending, we have to return a ticking promise.
if (this.pending) {
let resolve_;
const tickingPromise = new TickingPromise((resolve) => {
resolve_ = resolve;
});
tickingPromise.ticker = (elapsed) => {
this.tick(context, elapsed);
}
this.once('actionsFinished', () => {
resolve_();
});
return tickingPromise;
}
}
} }