3.5 KiB
3.5 KiB
PHY Item Attribute System (GIS)
本次新增
Source/PHYInventory/Private/GameplayTags/PHYInventoryItemTags.hSource/PHYInventory/Private/GameplayTags/PHYInventoryItemTags.cppSource/PHYInventory/Private/Items/PHYItemFragment_PropertySet.hSource/PHYInventory/Private/Items/PHYItemFragment_PropertySet.cppSource/PHYInventory/Private/Items/PHYItemBlueprintLibrary.hSource/PHYInventory/Private/Items/PHYItemBlueprintLibrary.cppSource/PHY/Private/Character/PHYCharacter.hSource/PHY/Private/Character/PHYCharacter.cppSource/PHY/Private/Character/PHYPlayerCharacter.hSource/PHY/Private/Character/PHYPlayerCharacter.cppSource/PHY/Private/Gameplay/Player/PHYPlayerState.hSource/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.RestoreHealthGIS.Attribute.Item.Consumable.RestoreInnerPower
设计
- 基于 GIS 的
UGIS_ItemDefinition+ Fragment。 - 新增
UPHYItemFragment_PropertySet作为统一“武器/装备/药品”属性片段。 - 道具实例创建时会把
BaseFloatModifiers/BaseIntegerModifiers写入UGIS_ItemInstance动态属性。
主要能力
- 统一道具大类:
EPHYItemArchetypeWeaponEquipmentConsumableMaterialQuest
- 统一装备槽:
EPHYEquipSlotType - 药品效果载荷:
FPHYConsumablePayloadRestoreHealthRestoreInnerPowerDurationSeconds
GameplayTags 管理
标签已集中在 Source/PHYInventory/Private/GameplayTags/PHYInventoryItemTags.*,避免代码中散落字符串:
GIS.Item.Type.WeaponGIS.Item.Type.EquipmentGIS.Item.Type.ConsumableGIS.Item.EquipSlot.MainHand等GIS.Attribute.Item.Attack、GIS.Attribute.Item.CritRate等
如何创建三类物品
- 在编辑器创建
UGIS_ItemDefinition资产。 - 给该资产添加 Fragment:
PHY Item Property Settings。 - 按类型配置:
- 武器:
ItemArchetype=Weapon,EquipSlot=MainHand/OffHand,填写攻击/暴击等属性。 - 装备:
ItemArchetype=Equipment,设置对应EquipSlot,填写防御/免伤/韧性等属性。 - 药品:
ItemArchetype=Consumable,填写ConsumablePayload(回血/回内力)。
- 武器:
- 把物品加入你的掉落表/默认背包配置。
蓝图辅助
UPHYItemBlueprintLibrary 提供:
GetItemArchetypeGetEquipSlotTypeIsWeaponItemIsEquipmentItemIsConsumableItemGetConsumablePayload
用于 UI 显示和使用逻辑分流。
备注
- 当前为 MVP:先打通类型与属性承载。
- 下一步可扩展:随机词条(Roll)、品质颜色、套装、与 GAS GameplayEffect 自动联动。