Files
PHY/PHY_Editor_Integration_Checklist.md
2026-03-05 14:44:34 +08:00

138 lines
4.3 KiB
Markdown
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.
# PHY 编辑器打通清单(装备/药品/通知)
> 目标:打通你当前 C++ 已实现的链路:
> - 装备穿脱 -> 属性生效/回滚
> - 药品使用Server RPC-> 扣除库存 -> 恢复属性
> - 通知飘字Info/Reward/Warning
## 0. 代码前提(已实现)
- `APHYCharacter` 已挂载:`InventorySystem` + `EquipmentSystem`
- 服务器 `BeginPlay` 会初始化库存与装备系统。
- `APHYPlayerCharacter::ServerUseConsumableByItemId` 已有严格校验:
- 必须是 `GIS.Item.Type.Consumable`
- 找不到道具/扣除失败会发 Warning 通知
- `APHYPlayerState` 已接入 owner 通知分发(支持 DS/Listen/Standalone
## 1. GameplayTags必须先做
请在 `Project Settings -> Gameplay Tags``Config/DefaultGameplayTags.ini` 中确认存在:
### 1.1 类型标签(必须)
- `GIS.Item.Type.Weapon`
- `GIS.Item.Type.Equipment`
- `GIS.Item.Type.Consumable`
- `GIS.Item.Type.Material`
### 1.2 药品效果标签(必须)
- `GIS.Attribute.Item.Consumable.RestoreHealth`
- `GIS.Attribute.Item.Consumable.RestoreInnerPower`
### 1.3 装备属性标签(建议)
- `GIS.Attribute.Item.Attack`
- `GIS.Attribute.Item.Defense`
- `GIS.Attribute.Item.CritRate`
- `GIS.Attribute.Item.CritDamage`
- `GIS.Attribute.Item.Hit`
- `GIS.Attribute.Item.Dodge`
- `GIS.Attribute.Item.Parry`
- `GIS.Attribute.Item.CounterChance`
- `GIS.Attribute.Item.ArmorPenetration`
- `GIS.Attribute.Item.DamageReduction`
- `GIS.Attribute.Item.LifeSteal`
- `GIS.Attribute.Item.Resilience`
- `GIS.Attribute.Item.MoveSpeed`
- `GIS.Attribute.Item.HealthRegenRate`
- `GIS.Attribute.Item.InnerPowerRegenRate`
- `GIS.Attribute.Item.MaxHealth`
- `GIS.Attribute.Item.MaxInnerPower`
## 2. 角色蓝图组件配置
打开你的玩家角色蓝图(继承 `APHYPlayerCharacter`
1. 选中 `InventorySystem` 组件:
- 确认存在普通背包集合(如 `GIS.Collection.Inventory`
- 确认存在装备槽集合(如 `GIS.Collection.Equipped`SlotCollection
2. 选中 `EquipmentSystem` 组件:
- `TargetCollectionTag` 设为装备槽集合标签(如 `GIS.Collection.Equipped`
> 若 `TargetCollectionTag` 不匹配,装备状态事件不会触发,属性不会生效。
## 3. 创建三类物品UGIS_ItemDefinition
## 3.1 药品示例:`ID_Cons_HealthSmall`
- `DisplayName`: 小还丹
- `ItemTags`: 添加 `GIS.Item.Type.Consumable`
- 图标:设置 `Icon`
- 动态或静态属性至少配置其一:
- `GIS.Attribute.Item.Consumable.RestoreHealth = 120`
- `GIS.Attribute.Item.Consumable.RestoreInnerPower = 0`
## 3.2 武器示例:`ID_Wpn_BronzeSword`
- `DisplayName`: 青铜剑
- `ItemTags`: 添加 `GIS.Item.Type.Weapon`
- 属性:
- `GIS.Attribute.Item.Attack = 35`
- `GIS.Attribute.Item.CritRate = 0.03`
## 3.3 装备示例:`ID_Equip_ClothArmor`
- `DisplayName`: 布甲
- `ItemTags`: 添加 `GIS.Item.Type.Equipment`
- 属性:
- `GIS.Attribute.Item.Defense = 20`
- `GIS.Attribute.Item.DamageReduction = 0.02`
## 4. 物品“使用”按钮绑定UI
在你的物品操作逻辑中(右键菜单/快捷键):
1.`UItemData``ItemInfo.Item`
2. `Item->GetItemId()` 拿到 `FGuid`
3. `GetOwningPlayerPawn` -> Cast `APHYPlayerCharacter`
4. 调用:`ServerUseConsumableByItemId(ItemId, 1)`
## 5. 通知验证点
你当前 UI 会接 `OnGameplayNotifyDelegate`,预期:
- 使用药品成功:`Reward`(例如:使用 小还丹 x1
- 使用非药品:`Warning`
- 数量不足/扣除失败:`Warning`
- 装备成功:`Info`(装备 xxx
- 卸下成功:`Info`(卸下 xxx
## 6. 联机验收顺序(建议)
1. Standalone
2. Listen Server + 1 Client
3. Dedicated Server + 1 Client
每轮都检查:
- 药品是否扣库存
- 生命/内力是否恢复
- 装备/卸下是否改变属性
- 通知是否只在拥有者客户端显示
## 7. 常见问题
- **现象:药品点了无反应**
- 常见原因:缺少 `GIS.Item.Type.Consumable`
- **现象:装备后属性不变**
- 常见原因:`EquipmentSystem.TargetCollectionTag` 不匹配装备集合
- **现象Dedicated Server 下无提示**
- 先确认 HUD/UI 绑定是否在客户端建立;`PlayerState` 已支持 owner 通知分发
---
如果你需要,我可以继续生成第二份文档:
- `PHY_Item_Asset_Convention.md`(命名规范 + 品质色 + 图标规范 + 掉落表字段模板)