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.
AdLike2048/assets/script/battle/bond/InBattleBondHost.ts

73 lines
2.4 KiB

3 weeks ago
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';
1 week ago
import { removeBondModifiers } from './BondEffectApplier';
3 weeks ago
import { entriesAffectingWeapon } from '../skill/GlobalSkillEffects';
import { getTowerLoadoutService } from '../combat/TowerLoadoutService';
1 week ago
/**
* 局内羁绊宿主(旧词条 Skill.group / group2 已从配表删除)。
* 保留调用点:仅清掉历史 bond modifier,不再物化属性。
*/
3 weeks ago
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;
}
1 week ago
/** 旧 group2 翻倍已废弃;恒为 1 */
getGroup2StackMultiplier(_entry: ITableSkill): number {
return 1;
3 weeks ago
}
1 week ago
/** 清已部署单位上的羁绊 modifier(词条表已删,不做物化) */
3 weeks ago
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;
1 week ago
removeBondModifiers(session, entityId);
3 weeks ago
}
}
refreshEntity(entityId: EntityId, player: Player): void {
const loadout = getTowerLoadoutService().getLoadout(entityId);
if (!loadout) return;
1 week ago
// 保持调用形态;entriesAffectingWeapon 已恒空
entriesAffectingWeapon(player.selectedSkills, loadout.weapon1Id);
3 weeks ago
const runtime = this._runtime;
1 week ago
if (!runtime?.session.world.isAlive(entityId)) return;
removeBondModifiers(runtime.session, entityId);
3 weeks ago
}
}
let _host: InBattleBondHost | null = null;
1 week ago
/** 局内羁绊宿主单例 */
3 weeks ago
export function getInBattleBondHost(): InBattleBondHost {
if (!_host) _host = new InBattleBondHost();
return _host;
}
1 week ago
/** 测试重置 */
3 weeks ago
export function resetInBattleBondHostForTests(): void {
_host = null;
}