168 lines
5.3 KiB
C++
168 lines
5.3 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
|
#include "AbilitySystem/Attributes/PHYAttributeSettings.h"
|
|
#include "PHYAttributeCalculationLibrary.generated.h"
|
|
|
|
class UPHYCoreAttributeSet;
|
|
|
|
/**
|
|
* @brief 基础属性输入快照,用于 C++、GE 和后续 MMC 共享公式。
|
|
*/
|
|
USTRUCT(BlueprintType)
|
|
struct FPHYCoreAttributeSnapshot
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
/** @brief 力量。 */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="PHY|Attributes|Core")
|
|
float Strength = 0.0f;
|
|
|
|
/** @brief 灵巧。 */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="PHY|Attributes|Core")
|
|
float Dexterity = 0.0f;
|
|
|
|
/** @brief 体魄。 */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="PHY|Attributes|Core")
|
|
float Vitality = 0.0f;
|
|
|
|
/** @brief 智力。 */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="PHY|Attributes|Core")
|
|
float Intelligence = 0.0f;
|
|
|
|
/** @brief 精神。 */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="PHY|Attributes|Core")
|
|
float Spirit = 0.0f;
|
|
|
|
/** @brief 感知。 */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="PHY|Attributes|Core")
|
|
float Perception = 0.0f;
|
|
};
|
|
|
|
/**
|
|
* @brief 次级战斗属性计算结果。
|
|
*/
|
|
USTRUCT(BlueprintType)
|
|
struct FPHYDerivedCombatAttributes
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
/** @brief 推导后的生命上限。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float MaxHealth = 0.0f;
|
|
|
|
/** @brief 推导后的法力上限。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float MaxMana = 0.0f;
|
|
|
|
/** @brief 推导后的耐力上限。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float MaxStamina = 0.0f;
|
|
|
|
/** @brief 推导后的物理攻击强度。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float PhysicalAttackPower = 0.0f;
|
|
|
|
/** @brief 推导后的法术强度。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float SpellPower = 0.0f;
|
|
|
|
/** @brief 推导后的护甲。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float Armor = 0.0f;
|
|
|
|
/** @brief 推导后的魔法抗性。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float MagicResistance = 0.0f;
|
|
|
|
/** @brief 推导后的命中率。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float Accuracy = 0.0f;
|
|
|
|
/** @brief 推导后的闪避率。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float Evasion = 0.0f;
|
|
|
|
/** @brief 推导后的暴击率。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float CriticalChance = 0.0f;
|
|
|
|
/** @brief 推导后的暴击伤害倍率。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float CriticalDamage = 0.0f;
|
|
|
|
/** @brief 推导后的攻击速度倍率。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float AttackSpeed = 0.0f;
|
|
|
|
/** @brief 推导后的冷却缩减比例。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float CooldownReduction = 0.0f;
|
|
|
|
/** @brief 推导后的格挡强度。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float BlockPower = 0.0f;
|
|
|
|
/** @brief 推导后的破防强度。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float GuardBreakPower = 0.0f;
|
|
|
|
/** @brief 推导后的韧性。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float Poise = 0.0f;
|
|
|
|
/** @brief 推导后的韧性伤害。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Combat")
|
|
float PoiseDamage = 0.0f;
|
|
};
|
|
|
|
/**
|
|
* @brief 元素属性计算结果。
|
|
*/
|
|
USTRUCT(BlueprintType)
|
|
struct FPHYDerivedElementAttributes
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
/** @brief 推导后的通用元素伤害加成。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Element")
|
|
float DamageBonus = 0.0f;
|
|
|
|
/** @brief 推导后的通用元素抗性。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Element")
|
|
float Resistance = 0.0f;
|
|
|
|
/** @brief 推导后的通用元素穿透。 */
|
|
UPROPERTY(BlueprintReadOnly, Category="PHY|Attributes|Element")
|
|
float Penetration = 0.0f;
|
|
};
|
|
|
|
/**
|
|
* @brief 属性公式函数库,避免首期依赖复杂 MMC 资产。
|
|
*/
|
|
UCLASS()
|
|
class PHY_API UPHYAttributeCalculationLibrary : public UBlueprintFunctionLibrary
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
/** @brief 从配置默认值创建基础属性快照。 */
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Attributes")
|
|
static FPHYCoreAttributeSnapshot MakeCoreSnapshotFromDefaults();
|
|
|
|
/** @brief 从基础属性集创建基础属性快照。 */
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Attributes")
|
|
static FPHYCoreAttributeSnapshot MakeCoreSnapshotFromAttributeSet(const UPHYCoreAttributeSet* CoreAttributes);
|
|
|
|
/** @brief 根据基础属性和配置公式计算次级战斗属性。 */
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Attributes")
|
|
static FPHYDerivedCombatAttributes CalculateCombatAttributes(const FPHYCoreAttributeSnapshot& CoreAttributes);
|
|
|
|
/** @brief 根据基础属性和配置公式计算通用元素属性。 */
|
|
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PHY|Attributes")
|
|
static FPHYDerivedElementAttributes CalculateElementAttributes(const FPHYCoreAttributeSnapshot& CoreAttributes);
|
|
};
|