|
|
|
|
import type { EntityId } from 'db://assets/mx/module/ecs';
|
|
|
|
|
import type { IBattleRuntimeHandle } from '../types/ProjectBattleTypes';
|
|
|
|
|
import type { Player } from '../../game/Player';
|
|
|
|
|
import type { TextGrid } from '../view/TextGrid';
|
|
|
|
|
import { removeBondModifiers } from './BondEffectApplier';
|
|
|
|
|
import { entriesAffectingWeapon } from '../skill/GlobalSkillEffects';
|
|
|
|
|
import { getTowerLoadoutService } from '../combat/TowerLoadoutService';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 局内羁绊宿主(旧词条 Skill.group / group2 已从配表删除)。
|
|
|
|
|
* 保留调用点:仅清掉历史 bond modifier,不再物化属性。
|
|
|
|
|
*/
|
|
|
|
|
export class InBattleBondHost {
|
|
|
|
|
private _runtime: IBattleRuntimeHandle | null = null;
|
|
|
|
|
private _mapGrids: ReadonlyMap<number, TextGrid> | undefined;
|
|
|
|
|
|
|
|
|
|
bindRuntime(runtime: IBattleRuntimeHandle): void {
|
|
|
|
|
this._runtime = runtime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bindMapGrids(mapGrids: ReadonlyMap<number, TextGrid> | undefined): void {
|
|
|
|
|
this._mapGrids = mapGrids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get mapGrids(): ReadonlyMap<number, TextGrid> | undefined {
|
|
|
|
|
return this._mapGrids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unbind(): void {
|
|
|
|
|
this._runtime = null;
|
|
|
|
|
this._mapGrids = undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 旧 group2 翻倍已废弃;恒为 1 */
|
|
|
|
|
getGroup2StackMultiplier(_entry: ITableSkill): number {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 清已部署单位上的羁绊 modifier(词条表已删,不做物化) */
|
|
|
|
|
refreshPlayer(player: Player): void {
|
|
|
|
|
const runtime = this._runtime;
|
|
|
|
|
if (!runtime) return;
|
|
|
|
|
const session = runtime.session;
|
|
|
|
|
for (const entityId of player.deployedUnits) {
|
|
|
|
|
if (!session.world.isAlive(entityId)) continue;
|
|
|
|
|
removeBondModifiers(session, entityId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
refreshEntity(entityId: EntityId, player: Player): void {
|
|
|
|
|
const loadout = getTowerLoadoutService().getLoadout(entityId);
|
|
|
|
|
if (!loadout) return;
|
|
|
|
|
// 保持调用形态;entriesAffectingWeapon 已恒空
|
|
|
|
|
entriesAffectingWeapon(player.selectedSkills, loadout.weapon1Id);
|
|
|
|
|
const runtime = this._runtime;
|
|
|
|
|
if (!runtime?.session.world.isAlive(entityId)) return;
|
|
|
|
|
removeBondModifiers(runtime.session, entityId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let _host: InBattleBondHost | null = null;
|
|
|
|
|
|
|
|
|
|
/** 局内羁绊宿主单例 */
|
|
|
|
|
export function getInBattleBondHost(): InBattleBondHost {
|
|
|
|
|
if (!_host) _host = new InBattleBondHost();
|
|
|
|
|
return _host;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 测试重置 */
|
|
|
|
|
export function resetInBattleBondHostForTests(): void {
|
|
|
|
|
_host = null;
|
|
|
|
|
}
|