# PHY Item Attribute System (GIS) ## 本次新增 - `Source/PHYInventory/Private/GameplayTags/PHYInventoryItemTags.h` - `Source/PHYInventory/Private/GameplayTags/PHYInventoryItemTags.cpp` - `Source/PHYInventory/Private/Items/PHYItemFragment_PropertySet.h` - `Source/PHYInventory/Private/Items/PHYItemFragment_PropertySet.cpp` - `Source/PHYInventory/Private/Items/PHYItemBlueprintLibrary.h` - `Source/PHYInventory/Private/Items/PHYItemBlueprintLibrary.cpp` - `Source/PHY/Private/Character/PHYCharacter.h` - `Source/PHY/Private/Character/PHYCharacter.cpp` - `Source/PHY/Private/Character/PHYPlayerCharacter.h` - `Source/PHY/Private/Character/PHYPlayerCharacter.cpp` - `Source/PHY/Private/Gameplay/Player/PHYPlayerState.h` - `Source/PHY/Private/Gameplay/Player/PHYPlayerState.cpp` ## 新增联动能力(12) ### 1) 装备属性自动生效/回滚(服务器权威) - 在基础角色上新增 `UGIS_EquipmentSystemComponent`。 - 服务器 `BeginPlay` 时:先初始化 `InventorySystem`,再初始化 `EquipmentSystem`。 - `APHYPlayerCharacter` 监听 `OnEquipmentStateChangedEvent`。 - 事件触发后通过 `APHYPlayerState::HandleItemEquippedState` 应用或回滚属性。 - 使用 `AppliedEquipmentItems` 防止同一个 ItemId 重复叠加。 ### 2) 药品 Server RPC 使用链路 - 在 `APHYPlayerCharacter` 新增: - `UFUNCTION(Server, Reliable) ServerUseConsumableByItemId(FGuid ItemId, int32 Count=1)` - 服务端流程: - 按 `ItemId` 在库存中查找道具 - 扣减库存数量(`RemoveItem`) - 调用 `APHYPlayerState::ApplyConsumableFromItem` 应用恢复 - 当前默认读取道具动态属性标签: - `GIS.Attribute.Item.Consumable.RestoreHealth` - `GIS.Attribute.Item.Consumable.RestoreInnerPower` ## 设计 - 基于 GIS 的 `UGIS_ItemDefinition` + Fragment。 - 新增 `UPHYItemFragment_PropertySet` 作为统一“武器/装备/药品”属性片段。 - 道具实例创建时会把 `BaseFloatModifiers` / `BaseIntegerModifiers` 写入 `UGIS_ItemInstance` 动态属性。 ## 主要能力 - 统一道具大类:`EPHYItemArchetype` - `Weapon` - `Equipment` - `Consumable` - `Material` - `Quest` - 统一装备槽:`EPHYEquipSlotType` - 药品效果载荷:`FPHYConsumablePayload` - `RestoreHealth` - `RestoreInnerPower` - `DurationSeconds` ## GameplayTags 管理 标签已集中在 `Source/PHYInventory/Private/GameplayTags/PHYInventoryItemTags.*`,避免代码中散落字符串: - `GIS.Item.Type.Weapon` - `GIS.Item.Type.Equipment` - `GIS.Item.Type.Consumable` - `GIS.Item.EquipSlot.MainHand` 等 - `GIS.Attribute.Item.Attack`、`GIS.Attribute.Item.CritRate` 等 ## 如何创建三类物品 1. 在编辑器创建 `UGIS_ItemDefinition` 资产。 2. 给该资产添加 Fragment:`PHY Item Property Settings`。 3. 按类型配置: - 武器:`ItemArchetype=Weapon`,`EquipSlot=MainHand/OffHand`,填写攻击/暴击等属性。 - 装备:`ItemArchetype=Equipment`,设置对应 `EquipSlot`,填写防御/免伤/韧性等属性。 - 药品:`ItemArchetype=Consumable`,填写 `ConsumablePayload`(回血/回内力)。 4. 把物品加入你的掉落表/默认背包配置。 ## 蓝图辅助 `UPHYItemBlueprintLibrary` 提供: - `GetItemArchetype` - `GetEquipSlotType` - `IsWeaponItem` - `IsEquipmentItem` - `IsConsumableItem` - `GetConsumablePayload` 用于 UI 显示和使用逻辑分流。 ## 备注 - 当前为 MVP:先打通类型与属性承载。 - 下一步可扩展:随机词条(Roll)、品质颜色、套装、与 GAS GameplayEffect 自动联动。