You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.0 KiB
31 lines
1.0 KiB
|
3 weeks ago
|
import { BattlePhase } from '../battle';
|
||
|
|
import { LoadScheduler } from './LoadScheduler';
|
||
|
|
import { membershipFromArray, type ReadonlyMembershipSet } from '../../tools/MembershipSet';
|
||
|
|
|
||
|
|
/** 战斗 COMBAT 阶段禁止后台 IO;PREP / 暂停 / 结算 / 战斗结束后允许分帧预载 */
|
||
|
|
const ALLOWED_BATTLE_PHASES: ReadonlyMembershipSet<BattlePhase> = membershipFromArray([
|
||
|
|
BattlePhase.PREP,
|
||
|
|
BattlePhase.PAUSE,
|
||
|
|
BattlePhase.WAIT_REVIVE,
|
||
|
|
BattlePhase.END,
|
||
|
|
]);
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 战斗期间大厅资源后台预载门闩:仅非 COMBAT 相位消耗 background 队列预算。
|
||
|
|
*/
|
||
|
|
export class BattleBackgroundLoadGate {
|
||
|
|
private static _installed = false;
|
||
|
|
|
||
|
|
static install(): void {
|
||
|
|
if (this._installed) return;
|
||
|
|
this._installed = true;
|
||
|
|
LoadScheduler.getInstance().setBackgroundAllowed(() => this.isAllowed());
|
||
|
|
}
|
||
|
|
|
||
|
|
static isAllowed(): boolean {
|
||
|
|
const session = gg.battle.match?.session;
|
||
|
|
if (!session) return true;
|
||
|
|
return ALLOWED_BATTLE_PHASES.has(session.phase);
|
||
|
|
}
|
||
|
|
}
|