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.
49 lines
1.3 KiB
49 lines
1.3 KiB
import type { BattleServices } from './BattleServices';
|
|
import type { EntityId } from 'db://assets/mx/module/ecs';
|
|
import type { SeededRNG } from '../core/SeededRNG';
|
|
|
|
/** 技能/效果执行上下文 */
|
|
export interface AbilityContext {
|
|
/** 战斗服务聚合(供 effect/condition 脚本访问各子系统) */
|
|
services: BattleServices;
|
|
/** 施放者实体 ID */
|
|
caster: EntityId;
|
|
/** 技能 ID */
|
|
abilityId: string;
|
|
/** 技能等级 */
|
|
level: number;
|
|
/** 目标实体 ID 列表 */
|
|
targets: EntityId[];
|
|
/** 可选目标点(格子坐标) */
|
|
point?: { row: number; col: number };
|
|
/** 父级上下文(嵌套触发) */
|
|
parent?: AbilityContext;
|
|
/** 随机数生成器 */
|
|
rng: SeededRNG;
|
|
/** 运行时变量表 */
|
|
vars: Map<string, number>;
|
|
}
|
|
|
|
/**
|
|
* @param services 战斗服务聚合
|
|
* @param caster 施放者实体 ID
|
|
* @param abilityId 技能 ID
|
|
* @param targets 目标列表,默认空
|
|
* @returns 初始化的技能上下文
|
|
*/
|
|
export function createAbilityContext(
|
|
services: BattleServices,
|
|
caster: EntityId,
|
|
abilityId: string,
|
|
targets: EntityId[] = [],
|
|
): AbilityContext {
|
|
return {
|
|
services,
|
|
caster,
|
|
abilityId,
|
|
level: 1,
|
|
targets,
|
|
rng: services.rng,
|
|
vars: new Map(),
|
|
};
|
|
}
|
|
|