wiki更新

This commit is contained in:
panw
2025-10-30 16:49:19 +08:00
parent 40e0086be3
commit 93ceaa70e4
18 changed files with 746 additions and 1100 deletions

View File

@@ -7,12 +7,35 @@
- [TalSet.ts](file://assets/script/game/common/config/TalSet.ts)
- [Hero.ts](file://assets/script/game/hero/Hero.ts)
- [HeroViewComp.ts](file://assets/script/game/hero/HeroViewComp.ts)
- [SkillConComp.ts](file://assets/script/game/hero/SkillConComp.ts)
- [HSkillSystem.ts](file://assets/script/game/hero/HSkillSystem.ts)
- [BuffComp.ts](file://assets/script/game/hero/BuffComp.ts)
- [TalComp.ts](file://assets/script/game/hero/TalComp.ts)
- [heroSet.ts](file://assets/script/game/common/config/heroSet.ts)
- [HeroAttrsComp.ts](file://assets/script/game/hero/HeroAttrsComp.ts)
- [HeroAtk.ts](file://assets/script/game/hero/HeroAtk.ts)
- [EBusComp.ts](file://assets/script/game/hero/EBusComp.ts)
</cite>
## 更新摘要
**变更内容**
- 移除了 `SkillConComp` 组件重构为基于ECS系统的技能控制机制
-`is_atking` 攻击状态从视图层 `HeroViewComp` 迁移到数据层 `HeroAttrsComp`
- 拆分通用移动组件为专属的英雄和怪物移动系统
- 在攻击和死亡事件中集成视觉反馈
- 根据ECS框架重构角色视图和数据逻辑新增事件总线组件 `EBusComp`
**新增章节**
- ECS架构下的技能系统
- 攻击与死亡事件的视觉反馈
**已移除章节**
- 原有的 `SkillConComp` 技能控制组件相关内容
**来源追踪系统更新**
- 更新了受影响文件的引用链接和行号范围
- 添加了新组件和系统的文件引用
- 标记了已移除组件的废弃状态
## 目录
1. [简介](#简介)
2. [系统架构概览](#系统架构概览)
@@ -27,7 +50,7 @@
## 简介
英雄系统是游戏的核心战斗机制负责管理英雄的属性、技能、天赋和状态。本系统采用模块化设计通过ECS架构实现组件间的松耦合通信支持复杂的战斗逻辑和动态效果管理。
英雄系统是游戏的核心战斗机制负责管理英雄的属性、技能、天赋和状态。本系统采用模块化设计通过ECS架构实现组件间的松耦合通信支持复杂的战斗逻辑和动态效果管理。近期重构移除了 `SkillConComp` 组件将技能控制逻辑迁移至基于ECS系统的 `HSkillSystem`,同时将攻击状态从视图层迁移至数据层,实现了更合理的数据与表现分离。
## 系统架构概览
@@ -41,25 +64,26 @@ BC[BuffComp<br/>状态显示组件]
end
subgraph "控制层"
HC[Hero<br/>英雄实体]
SC[SkillConComp<br/>技能控制组件]
SS[HSkillSystem<br/>技能系统]
TC[TalComp<br/>天赋控制组件]
end
subgraph "配置层"
HA[HeroAttrs<br/>属性配置]
SS[SkillSet<br/>技能配置]
SSC[SkillSet<br/>技能配置]
TS[TalSet<br/>天赋配置]
end
subgraph "数据层"
HAC[HeroAttrsComp<br/>属性数据组件]
HM[HeroModelComp<br/>模型数据]
MM[MonModelComp<br/>怪物数据]
end
HC --> HV
HC --> HM
SC --> HV
HC --> HAC
SS --> HV
TC --> HV
HV --> BC
HV --> HA
SC --> SS
SS --> SSC
TC --> TS
HV --> MM
```
@@ -67,7 +91,7 @@ HV --> MM
**图表来源**
- [Hero.ts](file://assets/script/game/hero/Hero.ts#L1-L100)
- [HeroViewComp.ts](file://assets/script/game/hero/HeroViewComp.ts#L1-L100)
- [SkillConComp.ts](file://assets/script/game/hero/SkillConComp.ts#L1-L50)
- [HSkillSystem.ts](file://assets/script/game/hero/HSkillSystem.ts#L1-L50)
- [TalComp.ts](file://assets/script/game/hero/TalComp.ts#L1-L50)
## 英雄属性系统
@@ -209,18 +233,54 @@ SkillConfig --> BuffConf
**图表来源**
- [SkillSet.ts](file://assets/script/game/common/config/SkillSet.ts#L80-L148)
### 技能控制逻辑
### ECS架构下的技能系统
技能释放遵循严格的时序控制
技能系统已重构为基于ECS的系统架构主要包含以下组件
```mermaid
classDiagram
class CastSkillRequestComp {
+skillIndex : number
+targetPositions : Vec3[]
+reset() void
}
class SkillCastSystem {
+filter() IMatcher
+entityEnter(e : Entity) void
+checkCastConditions() boolean
+executeCast() void
+createSkillEntity() void
}
class SkillCDSystem {
+filter() IMatcher
+update(e : Entity) void
+updateCDs(dt : number) void
}
class SkillAutocastSystem {
+filter() IMatcher
+update(e : Entity) void
+selectTargets() Vec3[]
}
CastSkillRequestComp --> SkillCastSystem
SkillCastSystem --> SkillCDSystem
SkillAutocastSystem --> CastSkillRequestComp
```
**章节来源**
- [HSkillSystem.ts](file://assets/script/game/hero/HSkillSystem.ts#L1-L271)
### 技能施法流程
技能施法遵循ECS标记组件驱动的时序控制
```mermaid
sequenceDiagram
participant Player as 玩家输入
participant SC as SkillConComp
participant SC as SkillAutocastSystem
participant HV as HeroViewComp
participant SE as SkillEnt
participant Target as 目标实体
Player->>SC : 技能冷却完成
Player->>SC : 添加CastSkillRequest
SC->>SC : 检查英雄状态
SC->>HV : 选择目标
HV-->>SC : 返回目标坐标
@@ -232,7 +292,7 @@ SE-->>HV : 更新状态
```
**图表来源**
- [SkillConComp.ts](file://assets/script/game/hero/SkillConComp.ts#L50-L120)
- [HSkillSystem.ts](file://assets/script/game/hero/HSkillSystem.ts#L100-L150)
### 目标选择算法
@@ -252,11 +312,11 @@ H --> I
```
**图表来源**
- [SkillConComp.ts](file://assets/script/game/hero/SkillConComp.ts#L130-L170)
- [HSkillSystem.ts](file://assets/script/game/hero/HSkillSystem.ts#L200-L250)
**章节来源**
- [SkillSet.ts](file://assets/script/game/common/config/SkillSet.ts#L1-L148)
- [SkillConComp.ts](file://assets/script/game/hero/SkillConComp.ts#L1-L177)
- [HSkillSystem.ts](file://assets/script/game/hero/HSkillSystem.ts#L1-L271)
## 天赋系统
@@ -355,7 +415,7 @@ P --> S[技能列表更新]
```mermaid
classDiagram
class HeroViewComp {
class HeroAttrsComp {
+BUFFS : Record~number, Array~
+BUFFS_TEMP : Record~number, Array~
+NeAttrs : Record~number, Object~
@@ -376,12 +436,12 @@ class NeAttrs {
+IN_BURN : 2
+IN_POISON : 3
}
HeroViewComp --> BuffInfo
HeroViewComp --> NeAttrs
HeroAttrsComp --> BuffInfo
HeroAttrsComp --> NeAttrs
```
**图表来源**
- [HeroViewComp.ts](file://assets/script/game/hero/HeroViewComp.ts#L80-L120)
- [HeroAttrsComp.ts](file://assets/script/game/hero/HeroAttrsComp.ts#L80-L120)
### 属性计算公式
@@ -397,25 +457,25 @@ HeroViewComp --> NeAttrs
```mermaid
sequenceDiagram
participant Game as 游戏循环
participant HV as HeroViewComp
participant HAC as HeroAttrsComp
participant Buff as Buff系统
participant Attr as 属性计算
Game->>HV : update(dt)
HV->>Buff : updateTemporaryBuffsDebuffs(dt)
Game->>HAC : update(dt)
HAC->>Buff : updateTemporaryBuffsDebuffs(dt)
Buff->>Buff : 减少剩余时间
Buff->>Buff : 移除过期buff
Buff->>Attr : recalculateSingleAttr()
Attr->>Attr : 重新计算属性值
Attr-->>HV : 更新后的属性
HV->>HV : clampSingleAttr()
HV-->>Game : 状态更新完成
Attr-->>HAC : 更新后的属性
HAC->>HAC : clampSingleAttr()
HAC-->>Game : 状态更新完成
```
**图表来源**
- [HeroViewComp.ts](file://assets/script/game/hero/HeroViewComp.ts#L400-L500)
- [HeroAttrsComp.ts](file://assets/script/game/hero/HeroAttrsComp.ts#L400-L500)
**章节来源**
- [HeroViewComp.ts](file://assets/script/game/hero/HeroViewComp.ts#L1-L780)
- [HeroAttrsComp.ts](file://assets/script/game/hero/HeroAttrsComp.ts#L1-L489)
- [BuffComp.ts](file://assets/script/game/hero/BuffComp.ts#L1-L213)
## 组件间通信机制
@@ -427,11 +487,11 @@ graph LR
subgraph "英雄实体"
E[Hero实体]
HV[HeroViewComp]
HC[HeroConComp]
BM[BattleMoveComp]
HAC[HeroAttrsComp]
BM[HeroMoveComp]
end
subgraph "技能系统"
SC[SkillConComp]
SS[HSkillSystem]
SE[SkillEnt]
end
subgraph "状态系统"
@@ -439,19 +499,19 @@ BC[BuffComp]
TC[TalComp]
end
E --> HV
E --> HC
E --> HAC
E --> BM
HC --> SC
SC --> SE
HAC --> SS
SS --> SE
HV --> BC
HV --> TC
TC --> HV
SC --> HV
SS --> HV
```
**图表来源**
- [Hero.ts](file://assets/script/game/hero/Hero.ts#L15-L35)
- [SkillConComp.ts](file://assets/script/game/hero/SkillConComp.ts#L15-L30)
- [HSkillSystem.ts](file://assets/script/game/hero/HSkillSystem.ts#L15-L30)
### 事件驱动通信
@@ -460,13 +520,13 @@ SC --> HV
| 事件类型 | 发送者 | 接收者 | 用途 |
|---------|-------|-------|------|
| GameEvent.MasterCalled | Hero | Talent系统 | 英雄召唤事件 |
| GameEvent.CastHeroSkill | SkillCon | 其他组件 | 技能释放通知 |
| GameEvent.CastHeroSkill | HSkillSystem | 其他组件 | 技能释放通知 |
| GameEvent.FightEnd | Battle | 所有组件 | 战斗结束事件 |
| GameEvent.HeroDead | HeroView | Talent系统 | 英雄死亡事件 |
**章节来源**
- [Hero.ts](file://assets/script/game/hero/Hero.ts#L1-L100)
- [SkillConComp.ts](file://assets/script/game/hero/SkillConComp.ts#L1-L50)
- [HSkillSystem.ts](file://assets/script/game/hero/HSkillSystem.ts#L1-L50)
- [TalComp.ts](file://assets/script/game/hero/TalComp.ts#L1-L50)
## 关键功能实现
@@ -477,7 +537,7 @@ SC --> HV
```mermaid
flowchart TD
A[玩家输入技能] --> B[SkillConComp接收]
A[玩家输入技能] --> B[HSkillSystem接收]
B --> C{英雄状态检查}
C --> |眩晕/冰冻| D[阻止技能释放]
C --> |正常状态| E[检查冷却时间]
@@ -495,7 +555,7 @@ M --> O[技能释放成功]
```
**图表来源**
- [SkillConComp.ts](file://assets/script/game/hero/SkillConComp.ts#L50-L100)
- [HSkillSystem.ts](file://assets/script/game/hero/HSkillSystem.ts#L50-L100)
### 属性升级系统
@@ -557,10 +617,38 @@ P --> C
- [TalComp.ts](file://assets/script/game/hero/TalComp.ts#L100-L170)
**章节来源**
- [SkillConComp.ts](file://assets/script/game/hero/SkillConComp.ts#L50-L177)
- [HSkillSystem.ts](file://assets/script/game/hero/HSkillSystem.ts#L50-L271)
- [HeroAttrs.ts](file://assets/script/game/common/config/HeroAttrs.ts#L500-L546)
- [TalComp.ts](file://assets/script/game/hero/TalComp.ts#L100-L171)
### 攻击与死亡事件的视觉反馈
攻击和死亡事件现在集成视觉反馈,增强游戏表现力:
```mermaid
sequenceDiagram
participant Attack as 攻击事件
participant HAC as HeroAttrsComp
participant HV as HeroViewComp
participant AtkSys as HeroAtkSystem
Attack->>HAC : 发起攻击
HAC->>AtkSys : doAttack()
AtkSys->>HV : do_atked()
HV->>HV : 显示伤害数字
HV->>HV : 播放受击动画
HV->>HV : 角色后退
Attack->>HAC : 造成伤害
HAC->>HAC : 更新血量
HAC->>HV : 检查死亡
HV->>HV : do_dead()
HV->>HV : 播放死亡特效
HV->>HV : 触发死亡事件
```
**章节来源**
- [HeroAtk.ts](file://assets/script/game/hero/HeroAtk.ts#L1-L247)
- [HeroViewComp.ts](file://assets/script/game/hero/HeroViewComp.ts#L200-L300)
## 性能优化考虑
### 内存管理优化
@@ -591,4 +679,4 @@ P --> C
4. **高效状态管理**: 实现了完整的Buff/Debuff生命周期管理
5. **松耦合架构**: 通过ECS和事件机制实现组件间的解耦通信
该系统为游戏提供了坚实的战斗基础,支持复杂的游戏玩法和深度的角色养成体验。通过合理的架构设计和性能优化,确保了系统的稳定性和可扩展性。
近期重构将技能控制逻辑迁移至ECS系统移除了 `SkillConComp` 组件,同时将攻击状态从视图层迁移至数据层,实现了更合理的数据与表现分离。该系统为游戏提供了坚实的战斗基础,支持复杂的游戏玩法和深度的角色养成体验。通过合理的架构设计和性能优化,确保了系统的稳定性和可扩展性。