Files
pixelheros/assets/script/game/hero/BuffComp.ts
pan c4e7f2584b feat(hero): 新增完整计时性Buff/Debuff系统
本次提交实现了游戏内完整的计时性增益/减益系统,包含:
1. 新增Buff配置表与运行时数据组件
2. 实现属性修饰器与最终属性计算逻辑
3. 完成Buff管理、计时结算与周期效果处理
4. 兼容旧有控制状态系统,支持平滑过渡
5. 附带完整的系统设计文档

同时关闭了两个闲置的任务界面节点。
2026-07-23 15:48:59 +08:00

45 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
/**
* 单个活跃 buff 实例(一层)。
* 每个 ActiveBuff 独立计时,叠层时会产生多个实例。
*/
export class ActiveBuff {
/** 对应 BuffList 中的配置 id */
config_id: number;
/** 剩余持续时间(秒) */
remaining: number;
/** 施法者实体 uuid用于伤害归属 */
source_uuid: number;
/** 施法者攻击力快照(用于 DoT/HoT 的 ap 缩放) */
source_ap_snapshot: number;
/** 周期效果累计时间(秒) */
tick_acc: number = 0;
constructor(cfg_id: number, dur: number, src_uuid: number, src_ap: number) {
this.config_id = cfg_id;
this.remaining = dur;
this.source_uuid = src_uuid;
this.source_ap_snapshot = src_ap;
}
}
/**
* Buff 组件 — 存储实体身上所有活跃的 buff/debuff。
*
* 数据结构:按 buff_id 分组,每组是若干层(每层独立计时)。
* 使用 ecs.Comp仅承载数据计时与结算逻辑由 BuffSystem 负责。
*/
@ecs.register('Buff')
export class BuffComp extends ecs.Comp {
/** 按 buff_id 分组,每组是若干层(每层独立计时) */
buffs: Map<number, ActiveBuff[]> = new Map();
/** buff 列表变更标记(预留 UI 消费) */
dirty_buffs: boolean = false;
reset() {
this.buffs.clear();
this.dirty_buffs = false;
}
}