|
|
|
|
import { Prefab } from 'cc';
|
|
|
|
|
import { createMembershipSet, membershipAdd } from '../../../mx/tools/MembershipSet';
|
|
|
|
|
import { ChapterNewPlayTypeEnum } from '../../game/ChapterPlayTypes';
|
|
|
|
|
import { TableNames } from '../../game/ConfigTableData';
|
|
|
|
|
import { ChapterLevelBuilder } from '../config/ChapterLevelBuilder';
|
|
|
|
|
import { WITCH_MECHANISM_MONSTER_ID } from './MechanismConstants';
|
|
|
|
|
import type { ResPakage } from 'db://assets/mx/module/res/ResourcesManager';
|
|
|
|
|
|
|
|
|
|
/** 机制预载 bundle 名(避免 ConfigRes ↔ MechanismResCollector 循环依赖) */
|
|
|
|
|
const MECH_BUNDLE = {
|
|
|
|
|
BattleGameMonster: 'battleGameMonster',
|
|
|
|
|
BattleGame: 'battleGame',
|
|
|
|
|
MechanismEffect: 'mechanismEffect',
|
|
|
|
|
BattleMap: 'battleMap',
|
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
|
|
export interface MechanismResEntry {
|
|
|
|
|
bundle: string;
|
|
|
|
|
path: string;
|
|
|
|
|
name: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function pushPrefab(ress: ResPakage['ress'], bundle: string, path: string, name: string): void {
|
|
|
|
|
ress.push({ name, bundle, path, type: Prefab });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parsePlayIdList(raw: string | undefined | null): number[] {
|
|
|
|
|
if (!raw) return [];
|
|
|
|
|
return raw.split(',')
|
|
|
|
|
.map((s) => Number(s.trim()))
|
|
|
|
|
.filter((n) => Number.isFinite(n) && n > 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 战斗预载机制 play id:
|
|
|
|
|
* - 道具模式:Replica.mechanism 全集(局内再随机子集,预载须覆盖池内全部)
|
|
|
|
|
* - 其它模式:章节 new_play
|
|
|
|
|
*/
|
|
|
|
|
export function resolveMechanismPlayIdsForBattleRes(_chapterId: number): number[] {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 按 play id 收集机制战斗资源(并入 BattleRes 预载包) */
|
|
|
|
|
export function collectMechanismBattleRes(playIds: number[]): MechanismResEntry[] {
|
|
|
|
|
const entries: MechanismResEntry[] = [];
|
|
|
|
|
const seen = createMembershipSet<string>();
|
|
|
|
|
|
|
|
|
|
const add = (bundle: string, path: string, name: string) => {
|
|
|
|
|
const key = `${bundle}|${path}|${name}`;
|
|
|
|
|
if (seen.has(key)) return;
|
|
|
|
|
membershipAdd(seen, key);
|
|
|
|
|
entries.push({ bundle, path, name });
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (const rawId of playIds) {
|
|
|
|
|
switch (rawId as ChapterNewPlayTypeEnum) {
|
|
|
|
|
case ChapterNewPlayTypeEnum.Witch: {
|
|
|
|
|
const row = gg.data.project.getMonsterDataByID(WITCH_MECHANISM_MONSTER_ID);
|
|
|
|
|
const prefab = row ? ChapterLevelBuilder.resolveMonsterPrefabFromRow(row) : null;
|
|
|
|
|
if (prefab) {
|
|
|
|
|
add(MECH_BUNDLE.BattleGameMonster, 'prefab/monster/', prefab);
|
|
|
|
|
}
|
|
|
|
|
add(MECH_BUNDLE.BattleGameMonster, 'prefab/', '怪物加血');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ChapterNewPlayTypeEnum.BloodMoon:
|
|
|
|
|
add(MECH_BUNDLE.BattleGameMonster, 'prefab/monster/', '机制黄风怪');
|
|
|
|
|
add(MECH_BUNDLE.BattleGameMonster, 'prefab/', '怪_加速');
|
|
|
|
|
break;
|
|
|
|
|
case ChapterNewPlayTypeEnum.Paratroops:
|
|
|
|
|
case ChapterNewPlayTypeEnum.BossAirdrop:
|
|
|
|
|
add(MECH_BUNDLE.MechanismEffect, 'prefab/新机制/', 'newMechanismParatroops');
|
|
|
|
|
break;
|
|
|
|
|
case ChapterNewPlayTypeEnum.VinesGrass:
|
|
|
|
|
add(MECH_BUNDLE.BattleGameMonster, 'prefab/monster/', '蜘蛛精');
|
|
|
|
|
break;
|
|
|
|
|
case ChapterNewPlayTypeEnum.Charm:
|
|
|
|
|
add(MECH_BUNDLE.BattleGameMonster, 'prefab/monster/', '狐狸精');
|
|
|
|
|
break;
|
|
|
|
|
case ChapterNewPlayTypeEnum.AccelerateGate:
|
|
|
|
|
add(MECH_BUNDLE.MechanismEffect, 'prefab/新机制/', 'newMechanismAccGate');
|
|
|
|
|
add(MECH_BUNDLE.BattleMap, 'prefab/障碍物/', '加速门');
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return entries;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function appendMechanismResToPackage(ress: ResPakage['ress'], playIds: number[]): void {
|
|
|
|
|
for (const e of collectMechanismBattleRes(playIds)) {
|
|
|
|
|
pushPrefab(ress, e.bundle, e.path, e.name);
|
|
|
|
|
}
|
|
|
|
|
}
|