添加描述文件
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
# PvPDemo
|
||||
|
||||
基于 Unreal Engine 5.7 的第三人称 PvP 对战 Demo,玩家与 AI Bot 在场景中拾取道具并相互攻击。项目以 **GAS(Gameplay Ability System)** 为核心战斗框架,结合行为树驱动 AI、MVVM 驱动 UI、DataTable 驱动配置,采用 C++ 与蓝图混合开发。
|
||||
|
||||
## 技术栈
|
||||
|
||||
- **引擎**:Unreal Engine 5.7
|
||||
- **语言**:C++ / Blueprint
|
||||
- **核心框架**:
|
||||
- GameplayAbilities(GAS)
|
||||
- AIModule + Behavior Tree
|
||||
- StateTree / GameplayStateTree
|
||||
- UMG + ModelViewViewModel(MVVM)
|
||||
- EnhancedInput
|
||||
- **第三方插件**:AdvancedSessions
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
PvPDemo/
|
||||
├── Config/ # 引擎与项目配置
|
||||
├── Source/PvPDemo/ # C++ 源码模块
|
||||
│ ├── Public/ Private/
|
||||
│ │ ├── PvPDemoCharacter.* # 玩家角色(含 ASC / AttributeSet)
|
||||
│ │ ├── BotCharacter.* # AI Bot 角色(含 ASC / AttributeSet)
|
||||
│ │ ├── MainAttributeSet.* # 属性集
|
||||
│ │ ├── MainAbilitySystemComponent.*
|
||||
│ │ ├── MainGameState.* MainPlayerState.* MainHUD.*
|
||||
│ │ ├── MainMVVMViewModelBase.*
|
||||
│ │ ├── Item/ItemActor.* # 道具 Actor 基类
|
||||
│ │ ├── GAS/Effect/ # GameplayEffect 相关
|
||||
│ │ ├── UMG/MainUI.*
|
||||
│ │ ├── TestFireBall.* TestGameplayEffect.*
|
||||
│ │ └── Variant_Combat / Variant_Platforming / Variant_SideScrolling
|
||||
│ └── PvPDemo.Build.cs
|
||||
├── Content/
|
||||
│ ├── PvPDemo/
|
||||
│ │ ├── Asset/ # 元素材质(Fire / Water / Thunder / Dark / Heal)
|
||||
│ │ ├── Blueprints/
|
||||
│ │ │ ├── AI/ # BB_AI / BT_AI / BP_AIController / BP_Bot + Tasks
|
||||
│ │ │ ├── GAS/ # GA_UseFirstItem + Effect/GE_*
|
||||
│ │ │ ├── Item/ # BP_Item / BP_ItemManager / BP_ItemSpawner / BP_Item_*
|
||||
│ │ │ ├── UMG/ # WBP_LoginUI / WBP_MainUI / Widget/*
|
||||
│ │ │ └── Data/ # MVVM_Main / S_GameModeDifficulty / S_ItemInfo
|
||||
│ │ └── Data/ # DT_GameMode / DT_ItemInfo
|
||||
│ └── ThirdPerson/ # GameMode / PlayerController / GameInstance / Maps
|
||||
├── Plugins/
|
||||
│ └── AdvancedSessions/
|
||||
└── PvPDemo.uproject
|
||||
```
|
||||
|
||||
## 核心系统
|
||||
|
||||
### GAS(Gameplay Ability System)
|
||||
- `APvPDemoCharacter` 与 `ABotCharacter` 均实现 `IAbilitySystemInterface`,持有 `AbilitySystemComponent` 与 `MainAttributeSet`。
|
||||
- `BotCharacter` 在 `PossessedBy` 时初始化 ASC、授予默认 Abilities、应用默认属性 Effect。
|
||||
- 元素道具对应一组 GameplayEffect:`GE_Fireball / GE_Waterball / GE_Thunderball / GE_Darkball / GE_Heal`。
|
||||
- `GA_UseFirstItem` 处理使用背包首位道具的能力。
|
||||
|
||||
### AI
|
||||
- `BP_Bot`(继承自 `ABotCharacter`)+ `BP_AIController` 驱动行为。
|
||||
- 行为树 `BT_AI` / 黑板 `BB_AI`,自定义任务:
|
||||
- `BTTask_FindNearestItem`:搜寻最近道具
|
||||
- `BTTask_PickupItem`:拾取
|
||||
- `BTTask_FindTargetPlayer`:锁定玩家
|
||||
- `BTTask_AttackTarget`:攻击
|
||||
|
||||
### Item 系统
|
||||
- `AItemActor`(C++ 基类)暴露 `ApplyEffectToTarget` 用于对目标施加 GameplayEffect。
|
||||
- 蓝图侧:`BP_Item` 基类 → 元素球 / 治疗 / 射击道具变体。
|
||||
- `BP_ItemSpawner` 负责场景生成,`BP_ItemManager` 统一管理。
|
||||
- `APvPDemoCharacter::HeldItem` 通过 `AddHeldItemTag` / `RemoveHeldItemTag` 维护持有道具的 GameplayTag。
|
||||
|
||||
### UI(MVVM)
|
||||
- 启用 `ModelViewViewModelModule` + `FieldNotification`。
|
||||
- `MainMVVMViewModelBase` 作为 ViewModel 基类,`MVVM_Main` 资产承载主界面数据。
|
||||
- 主界面:`WBP_MainUI`,子部件包含 `Widget_HealthBar` / `Widget_Backpack` / `Widget_ItemIcon`。
|
||||
- 登录界面:`WBP_LoginUI`。
|
||||
|
||||
### 数据驱动
|
||||
- `DT_GameMode`(行结构 `S_GameModeDifficulty`):游戏模式难度配置。
|
||||
- `DT_ItemInfo`(行结构 `S_ItemInfo`):道具信息。
|
||||
|
||||
## 入口配置
|
||||
|
||||
`Config/DefaultEngine.ini` 中:
|
||||
- `GameDefaultMap` / `EditorStartupMap`:`/Game/ThirdPerson/L_TestMap`
|
||||
- `GlobalDefaultGameMode`:`BP_ThirdPersonGameMode`
|
||||
- `GameInstanceClass`:`BP_GameInstance`
|
||||
- 渲染:DX12 + SM6、Lumen、Substrate、虚拟阴影、光线追踪开启
|
||||
|
||||
## 模块依赖
|
||||
|
||||
`Source/PvPDemo/PvPDemo.Build.cs`:
|
||||
|
||||
```
|
||||
Core, CoreUObject, Engine, InputCore, EnhancedInput,
|
||||
AIModule, StateTreeModule, GameplayStateTreeModule,
|
||||
UMG, Slate,
|
||||
GameplayAbilities, GameplayTags, GameplayTasks,
|
||||
ModelViewViewModel, FieldNotification
|
||||
```
|
||||
|
||||
`PvPDemo.uproject` 启用插件:
|
||||
`ModelingToolsEditorMode`(仅 Editor)、`StateTree`、`GameplayStateTree`、`GameplayAbilities`、`ModelViewViewModel`。
|
||||
|
||||
## 构建与运行
|
||||
|
||||
1. 安装 Unreal Engine **5.7**。
|
||||
2. 右键 `PvPDemo.uproject` → **Generate Visual Studio project files**。
|
||||
3. 用 `PvPDemo.sln` 编译 `Development Editor | Win64`。
|
||||
4. 双击 `PvPDemo.uproject` 启动编辑器,默认进入 `L_TestMap`。
|
||||
|
||||
## 开发约定
|
||||
|
||||
项目根目录的 `CLAUDE.md` 与 `AGENTS.md` 描述了协作约束,要点:
|
||||
|
||||
- 修改代码前先说明方案,不直接动手。
|
||||
- 默认不做编译检查,除非主动要求。
|
||||
- 简洁优先:不引入未被要求的特性、抽象与配置项。
|
||||
- 改动外科手术式:只改必要的行,不顺手"优化"周边代码。
|
||||
Reference in New Issue
Block a user