Merge pull request #813 from nonameShijian/PR-Branch

修复game.belongAsyncEvent指定不明确的问题
This commit is contained in:
Spmario233 2024-01-19 01:46:38 +08:00 committed by GitHub
commit 8407bed9a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 7 deletions

View File

@ -5366,10 +5366,11 @@ export class Game extends Uninstantable {
* @param { GameEventPromise } [belongAsyncEvent] * @param { GameEventPromise } [belongAsyncEvent]
*/ */
static async loop(belongAsyncEvent) { static async loop(belongAsyncEvent) {
if (!game.belongAsyncEventList) game.belongAsyncEventList = [];
if (belongAsyncEvent) { if (belongAsyncEvent) {
game.belongAsyncEvent = belongAsyncEvent; game.belongAsyncEventList.push(belongAsyncEvent);
} else if (game.belongAsyncEvent) { } else if (game.belongAsyncEventList.length) {
return game.loop(game.belongAsyncEvent); belongAsyncEvent = game.belongAsyncEventList.at(-1);
} }
while (true) { while (true) {
let event = (belongAsyncEvent && belongAsyncEvent.parent == _status.event) ? belongAsyncEvent : _status.event; let event = (belongAsyncEvent && belongAsyncEvent.parent == _status.event) ? belongAsyncEvent : _status.event;
@ -5447,8 +5448,8 @@ export class Game extends Uninstantable {
event.parent._result = event.result; event.parent._result = event.result;
} }
_status.event = event.parent; _status.event = event.parent;
if (game.belongAsyncEvent == event) { if (game.belongAsyncEventList.includes(event)) {
delete game.belongAsyncEvent; game.belongAsyncEventList.remove(event);
} }
_resolve(); _resolve();
// 此时应该退出了 // 此时应该退出了
@ -5457,8 +5458,8 @@ export class Game extends Uninstantable {
} }
} }
else { else {
if (game.belongAsyncEvent == event) { if (game.belongAsyncEventList.includes(event)) {
delete game.belongAsyncEvent; game.belongAsyncEventList.remove(event);
} }
return _resolve(); return _resolve();
} }