第一次提交

This commit is contained in:
不明不惑
2026-03-03 01:23:02 +08:00
commit 3e434877e8
1053 changed files with 102411 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GCS_CombatStructLibrary.h"
#include "Engine/DataAsset.h"
#include "GCS_AbilityActionSetSettings.generated.h"
class UGCS_LayeredMontageSelectionSet;
/**
* Data asset for defining ability action sets.
* 定义能力动作集的数据资产。
*/
UCLASS(BlueprintType, Const, meta=(DisplayName="GCS Ability Action Set"))
class GENERICCOMBATSYSTEM_API UGCS_AbilityActionSetSettings : public UDataAsset
{
GENERATED_BODY()
public:
/**
* Selects the best ability actions based on tags.
* 根据标签选择最佳能力动作。
* @param SourceTags Tags for the source. 来源标签。
* @param TargetTags Tags for the target. 目标标签。
* @param AbilityTags Tags for the ability. 能力标签。
* @param Actions The matched ability actions (output). 匹配的能力动作(输出)。
* @return True if selection is successful. 如果选择成功返回true。
*/
UFUNCTION(BlueprintCallable, BlueprintPure=false, Category = "GCS", meta=(AutoCreateRefTerm="TargetTags"))
bool SelectBestAbilityActions(const FGameplayTagContainer& SourceTags, const FGameplayTagContainer& TargetTags, const FGameplayTagContainer& AbilityTags, TArray<FGCS_AbilityAction>& Actions) const;
/**
* Array of ability action sets.
* 能力动作集数组。
*/
UPROPERTY(EditAnywhere, Category="GCS", meta=(TitleProperty="AbilityTag"))
TArray<FGCS_AbilityActionSet> ActionSets;
#if WITH_EDITORONLY_DATA
/**
* Called before saving in the editor.
* 编辑器中保存前调用。
* @param SaveContext The save context. 保存上下文。
*/
virtual void PreSave(FObjectPreSaveContext SaveContext) override;
#endif
};

View File

@@ -0,0 +1,142 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameplayEffect.h"
#include "Engine/DataTable.h"
#include "GameplayTagContainer.h"
#include "GGA_AbilitySystemStructLibrary.h"
#include "Runtime/Launch/Resources/Version.h"
#if ENGINE_MINOR_VERSION < 5
#include "InstancedStruct.h"
#else
#include "StructUtils/InstancedStruct.h"
#endif
#include "GCS_AttackDefinition.generated.h"
/**
* Base struct allow you to extend the attack definition's fields using C++.
* 基础结构体允许你通过C++拓展攻击定义的字段。
*/
USTRUCT(BlueprintType, meta=(Hidden))
struct GENERICCOMBATSYSTEM_API FGCS_AttackDefinitionExtension
{
GENERATED_BODY()
};
/**
* Structure defining an attack's properties.
* 定义攻击属性的结构。
*/
USTRUCT(BlueprintType, meta=(DisplayName="GCS Attack Definition"))
struct GENERICCOMBATSYSTEM_API FGCS_AttackDefinition : public FTableRowBase
{
GENERATED_BODY()
/**
* Tags describing the attack (e.g., Melee/Ranged, Slash/Strike).
* 描述攻击的标签(例如近战/远程、劈砍/打击)。
* @note Added as dynamic AssetTags to the gameplay effect spec.
* @注意 作为动态AssetTags添加到游戏效果规格。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Common")
FGameplayTagContainer AttackTags;
/**
* SetByCaller tag-to-float mappings for gameplay effect specs.
* 用于游戏效果规格的SetByCaller标签到浮点映射。
* @note Usage is flexible (e.g., damage correction factors).
* @注意 使用灵活(例如伤害修正系数)。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Common", meta=(ForceInlineRow))
TMap<FGameplayTag, float> SetByCallerMagnitudes;
/**
* Gameplay effect to apply to the hit target.
* 应用于命中目标的游戏效果。
* @note Modified during attack request processing.
* @注意 在攻击请求处理期间修改。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Gameplay Effects")
TSoftClassPtr<UGameplayEffect> TargetEffectClass;
/**
* Level of the target gameplay effect.
* 目标游戏效果的等级。
* @note If < 1, uses the ability's level.
* @注意 如果<1使用能力的等级。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Gameplay Effects")
int32 TargetEffectClassLevel{1};
/**
* Effect container to apply to the target.
* 应用于目标的效果容器。
* @note Used for instant targeting; ability level determines effect level.
* @注意 用于即时目标;能力等级决定效果等级。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Gameplay Effects", meta=(ForceInlineRow))
FGGA_GameplayEffectContainer TargetEffectContainer;
/**
* Gameplay cues to trigger on the target upon hit.
* 命中目标时触发的游戏反馈。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Gameplay Cues", meta=(Categories="GameplayCue"))
TArray<FGameplayTag> TargetGameplayCues;
/**
* Knockback distance applied to the target.
* 应用于目标的击退距离。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "HitReaction", meta=(Units="cm"))
float KnockbackDistance{100};
/**
* Multiplier for knockback effect.
* 击退效果的倍增器。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "HitReaction", meta=(ClampMin=1))
float KnockbackMultiplier{1};
/**
* Duration of animation stall on hit (disabled if <= 0).
* 命中时动画停滞的持续时间(<=0时禁用
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Feedback", meta=(ClampMin=0, Units="s"))
float HitStallingDuration{0};
/**
* Play rate factor for hit animation.
* 命中动画的播放速率因子。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Feedback", meta=(ClampMin=0.1, ClampMax=0.9))
float HitPlayRateFactor{0.1};
/**
* Native Instanced struct for extending the attack definition.
* 实例化结构体用于扩充攻击定义的字段。
* @attention For C++ users only. 仅针对C++用户。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Extension")
TInstancedStruct<FGCS_AttackDefinitionExtension> NativeExtension;
/**
* Blueprint Instanced struct for extending the attack definition.
* 实例化结构体用于扩充攻击定义的字段。
* @attention For blueprint users only. 仅针对蓝图用户。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Extension")
FInstancedStruct Extension;
/**
* User-defined settings for the attack.
* 攻击的用户定义设置。
*/
UE_DEPRECATED(1.5, "Using extension field to add custom fields!")
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Deprecated", meta=(ForceInlineRow, BaseStruct = "/Script/GenericCombatSystem.GCS_UserSetting"))
TMap<FGameplayTag, FInstancedStruct> UserSettings;
};

View File

@@ -0,0 +1,224 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameplayTagContainer.h"
#include "Bullet/GCS_BulletStructLibrary.h"
#include "GCS_AttackDefinition.h"
#include "UObject/Object.h"
#include "GCS_AttackRequest.generated.h"
/**
* Base class for all attack request types.
* 所有攻击请求类型的基类。
*/
UCLASS(Abstract, Blueprintable, BlueprintType, Const, DefaultToInstanced, EditInlineNew, meta=(DisplayName="GCS Attack Request"))
class UGCS_AttackRequest_Base : public UObject
{
GENERATED_BODY()
public:
/**
* Gets the attack definition handle.
* 获取攻击定义句柄。
* @return The attack definition handle. 攻击定义句柄。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, BlueprintNativeEvent, Category="GCS|Attack")
FDataTableRowHandle GetAttackDefinitionHandle() const;
/**
* Gets the attack definition.
* 获取攻击定义。
* @return The attack definition. 攻击定义。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GCS|Attack")
FGCS_AttackDefinition GetAttackDefinition() const;
};
/**
* Attack request for melee attacks.
* 近战攻击请求。
*/
UCLASS(meta=(DisplayName="GCS Attack Request (Melee)"))
class GENERICCOMBATSYSTEM_API UGCS_AttackRequest_Melee : public UGCS_AttackRequest_Base
{
GENERATED_BODY()
public:
/**
* Gets the attack definition handle.
* 获取攻击定义句柄。
* @return The attack definition handle. 攻击定义句柄。
*/
virtual FDataTableRowHandle GetAttackDefinitionHandle_Implementation() const override;
/**
* Tags for traces activated during the notify state.
* 在通知状态期间激活的追踪标签。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Attack")
FGameplayTagContainer TracesToControl;
protected:
/**
* Handle to the attack definition.
* 攻击定义的句柄。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Attack", meta=(RowType="/Script/GenericCombatSystem.GCS_AttackDefinition"))
FDataTableRowHandle AttackDefinitionHandle;
};
/**
* Enum for ability targeting source types.
* 能力目标来源类型的枚举。
*/
UENUM(BlueprintType)
enum class EGCS_AbilityTargetingSourceType : uint8
{
/**
* From the player's camera towards camera focus.
* 从玩家相机朝向相机焦点。
*/
CameraTowardsFocus,
/**
* From the pawn's location/socket, in the pawn's orientation.
* 从Pawn的位置/插槽沿Pawn的朝向。
*/
PawnForward,
/**
* From the pawn's location/socket, oriented towards camera focus.
* 从Pawn的位置/插槽,朝向相机焦点。
*/
PawnTowardsFocus,
/**
* From the weapon's location/socket, in the pawn's orientation.
* 从武器的位置/插槽沿Pawn的朝向。
*/
WeaponForward,
/**
* From the weapon's location/socket, towards camera focus.
* 从武器的位置/插槽,朝向相机焦点。
*/
WeaponTowardsFocus,
/**
* Custom targeting, requires overriding GetTargetingTransform.
* 自定义目标需重写GetTargetingTransform。
*/
Custom
};
/**
* Attack request for firing bullets.
* 发射子弹的攻击请求。
*/
UCLASS(Blueprintable, BlueprintType, Const, EditInlineNew, meta=(DisplayName="GCS Attack Request (Bullet)"))
class GENERICCOMBATSYSTEM_API UGCS_AttackRequest_Bullet : public UGCS_AttackRequest_Base
{
GENERATED_BODY()
public:
/**
* Gets the bullet definition.
* 获取子弹定义。
* @return The bullet definition. 子弹定义。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GCS|Attack")
FGCS_BulletDefinition GetBulletDefinition() const;
/**
* Gets the attack definition handle.
* 获取攻击定义句柄。
* @return The attack definition handle. 攻击定义句柄。
*/
virtual FDataTableRowHandle GetAttackDefinitionHandle_Implementation() const override;
/**
* Gets the targeting transform for the attack.
* 获取攻击的目标变换。
* @param SourcePawn The source pawn. 来源Pawn。
* @param Source The targeting source type. 目标来源类型。
* @return The targeting transform. 目标变换。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, BlueprintNativeEvent, Category = "GCS|Attack")
FTransform GetTargetingTransform(APawn* SourcePawn, EGCS_AbilityTargetingSourceType Source) const;
/**
* Gets the weapon targeting source location.
* 获取武器目标来源位置。
* @param SourcePawn The source pawn. 来源Pawn。
* @return The weapon source location. 武器来源位置。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, BlueprintNativeEvent, Category = "GCS|Attack")
FVector GetWeaponTargetingSourceLocation(APawn* SourcePawn) const;
/**
* Gets the pawn targeting source location.
* 获取Pawn目标来源位置。
* @param SourcePawn The source pawn. 来源Pawn。
* @return The pawn source location. Pawn来源位置。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, BlueprintNativeEvent, Category = "GCS|Attack")
FVector GetPawnTargetingSourceLocation(APawn* SourcePawn) const;
/**
* Handle to the bullet definition.
* 子弹定义的句柄。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Parameters, meta=(RowType="/Script/GenericCombatSystem.GCS_BulletDefinition"))
FDataTableRowHandle BulletDefinitionHandle;
/**
* Type of targeting source for the attack.
* 攻击的目标来源类型。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ExposeOnSpawn = true), Category = Parameters)
EGCS_AbilityTargetingSourceType TargetingSourceType{EGCS_AbilityTargetingSourceType::PawnForward};
/**
* Tag name for looking up the source component.
* 用于查找来源组件的标签名称。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ExposeOnSpawn = true), Category = Parameters, meta=(EditCondition="TargetingSourceType != EGCS_AbilityTargetingSourceType::CameraTowardsFocus"))
FName SourceComponentLookupTagName{NAME_None};
/**
* Source socket name, falls back to source location if not found.
* 来源插槽名称,如果未找到则回退到来源位置。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ExposeOnSpawn = true), Category = Parameters, meta=(EditCondition="TargetingSourceType != EGCS_AbilityTargetingSourceType::CameraTowardsFocus"))
FName SourceSocketName{NAME_None};
/**
* Weapon socket name, falls back to source location if not found.
* 武器插槽名称,如果未找到则回退到来源位置。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ExposeOnSpawn = true), Category = Parameters, meta=(EditCondition="TargetingSourceType != EGCS_AbilityTargetingSourceType::CameraTowardsFocus"))
FName SourceWeaponSocketName{NAME_None};
/**
* Additional offset to the source location.
* 来源位置的附加偏移。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (ExposeOnSpawn = true), Category = Parameters)
FVector LocationOffset{FVector::Zero()};
/**
* Whether targeting is required for the attack.
* 攻击是否需要目标。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Parameters)
bool bRequireTargeting{false};
/**
* Targeting preset for the attack.
* 攻击的目标预设。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Parameters)
TObjectPtr<UTargetingPreset> TargetingPreset;
};

View File

@@ -0,0 +1,205 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameplayEffectTypes.h"
#include "GCS_CombatStructLibrary.h"
#include "Net/Serialization/FastArraySerializer.h"
#include "UObject/Object.h"
#include "GCS_AttackResult.generated.h"
class UGCS_AttackRequest_Melee;
class UGCS_CombatFlow;
class UGCS_CombatSystemComponent;
/**
* Structure representing the result of a processed attack.
* 表示已处理攻击结果的结构。
*/
USTRUCT(BlueprintType)
struct GENERICCOMBATSYSTEM_API FGCS_AttackResult : public FFastArraySerializerItem
{
GENERATED_BODY()
void PostReplicatedAdd(const struct FGCS_AttackResultContainer& InArray);
/**
* Deprecated.
* 已经弃用。
*/
UE_DEPRECATED(1.5, "Use TaggedValues within FGCS_ContextPayload_Combat")
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="GCS", NotReplicated, meta=(DeprecatedProperty, DeprecationMessage="Use TaggedValues within FGCS_ContextPayload_Combat!"))
TArray<FGCS_TaggedValue> TaggedValues;
/**
* Optional object related to the attack.
* 与攻击相关的可选对象。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GCS")
TObjectPtr<const UObject> OptionalObject;
/**
* Context handle for the gameplay effect.
* 游戏效果的上下文句柄。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GCS")
FGameplayEffectContextHandle EffectContextHandle;
/**
* Aggregated source tags for the attack.
* 攻击的聚合来源标签。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GCS")
FGameplayTagContainer AggregatedSourceTags;
/**
* Aggregated target tags for the attack.
* 攻击的聚合目标标签。
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GCS")
FGameplayTagContainer AggregatedTargetTags;
/**
* Whether the attack result has been consumed.
* 攻击结果是否已被消耗。
*/
UPROPERTY(NotReplicated)
bool bConsumed{false};
/**
* Indicates this attack result was found in existing processed array with same prediction key.
* 表示此攻击结果在已处理攻击结果列表中有相同的预测Key。
*/
UPROPERTY(NotReplicated)
bool bWasPredicated{false};
/**
* Indicates this attack result was replicated via fast array serializer.
* 表示此攻击结果是经由fast array serializer同步而来。
*/
UPROPERTY(NotReplicated)
bool bWasReplicated{false};
};
/**
* Container for storing combat results with network serialization.
* 用于存储战斗结果的容器,支持网络序列化。
*/
USTRUCT(BlueprintType)
struct GENERICCOMBATSYSTEM_API FGCS_AttackResultContainer : public FFastArraySerializer
{
GENERATED_BODY()
/**
* Default constructor.
* 默认构造函数。
*/
FGCS_AttackResultContainer();
/**
* Constructor with combat flow and max size.
* 带有战斗流程和最大尺寸的构造函数。
* @param InCombatFlow The combat flow instance. 战斗流程实例。
* @param InMaxSize The maximum size of the container. 容器最大尺寸。
*/
FGCS_AttackResultContainer(UGCS_CombatFlow* InCombatFlow, int32 InMaxSize);
/**
* Constructor with combat system component and max size.
* 带有战斗系统组件和最大尺寸的构造函数。
* @param InCombatSystemComponent The combat system component. 战斗系统组件。
* @param InMaxSize The maximum size of the container. 容器最大尺寸。
*/
FGCS_AttackResultContainer(UGCS_CombatSystemComponent* InCombatSystemComponent, int32 InMaxSize);
/**
* Sets the owning combat system component.
* 设置所属战斗系统组件。
* @param InCombatSystemComponent The combat system component. 战斗系统组件。
*/
void SetOwningCombatSystem(UGCS_CombatSystemComponent* InCombatSystemComponent) { CombatSystemComponent = InCombatSystemComponent; }
/**
* Sets the combat flow.
* 设置战斗流程。
* @param InCombatFlow The combat flow instance. 战斗流程实例。
*/
void SetCombatFlow(UGCS_CombatFlow* InCombatFlow) { CombatFlow = InCombatFlow; }
/**
* Adds a new attack result entry to the container.
* 向容器添加新的攻击结果条目。
* @param NewEntry The attack result to add. 要添加的攻击结果。
*/
void AddEntry(FGCS_AttackResult& NewEntry);
/**
* Handles post-replication addition of entries.
* 处理条目添加后的复制。
* @param AddedIndices The indices of added entries. 添加的条目索引。
* @param FinalSize The final size of the container. 容器最终尺寸。
*/
void PostReplicatedAdd(const TArrayView<int32> AddedIndices, int32 FinalSize);
/**
* Handles post-replication changes to entries.
* 处理条目更改后的复制。
* @param ChangedIndices The indices of changed entries. 更改的条目索引。
* @param FinalSize The final size of the container. 容器最终尺寸。
*/
void PostReplicatedChange(const TArrayView<int32>& ChangedIndices, int32 FinalSize);
/**
* Serializes the container for network replication.
* 为网络复制序列化容器。
* @param DeltaParms The network serialization parameters. 网络序列化参数。
* @return True if serialization is successful. 如果序列化成功返回true。
*/
bool NetDeltaSerialize(FNetDeltaSerializeInfo& DeltaParms)
{
return FastArrayDeltaSerialize<FGCS_AttackResult, FGCS_AttackResultContainer>(Results, DeltaParms, *this);
}
bool HasPredictedResultWithPredictedKey(FPredictionKey PredictionKey) const;
private:
/**
* Reference to the combat flow instance.
* 战斗流程实例的引用。
*/
UPROPERTY()
TObjectPtr<UGCS_CombatFlow> CombatFlow;
/**
* Reference to the combat system component.
* 战斗系统组件的引用。
*/
UPROPERTY()
TObjectPtr<UGCS_CombatSystemComponent> CombatSystemComponent;
/**
* List of attack results.
* 攻击结果列表。
*/
UPROPERTY()
TArray<FGCS_AttackResult> Results;
/**
* Maximum size of the container.
* 容器最大尺寸。
*/
UPROPERTY()
int32 MaxSize;
};
template <>
struct TStructOpsTypeTraits<FGCS_AttackResultContainer> : TStructOpsTypeTraitsBase2<FGCS_AttackResultContainer>
{
enum
{
WithNetDeltaSerializer = true,
};
};

View File

@@ -0,0 +1,287 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GCS_AttackResult.h"
#include "UObject/Object.h"
#include "GCS_AttackResultProcessor.generated.h"
UENUM()
enum class EGCS_AttackResultProcessorPolicy
{
//execute when non-predicting cross all server and clients.
Default,
//execute in predicting client first,then server and other clients.same as default is not predicting.
LocalPredicted,
//execute only on server side.
ServerOnly
};
/**
* Base class for processing attack results.
* 处理攻击结果的基类。
*/
UCLASS(EditInlineNew, DefaultToInstanced, BlueprintType, Blueprintable, Abstract, Const)
class GENERICCOMBATSYSTEM_API UGCS_AttackResultProcessor : public UObject
{
GENERATED_BODY()
public:
/**
* Processes an incoming attack result.
* 处理传入的攻击结果。
* @param AttackResult The attack result to process. 要处理的攻击结果。
*/
UFUNCTION(BlueprintCallable, Category="GCS")
virtual bool ProcessIncomingAttackResult(const FGCS_AttackResult& AttackResult);
/**
* Gets the world context for the processor.
* 获取处理器的世界上下文。
* @return The world context. 世界上下文。
*/
virtual UWorld* GetWorld() const override;
UFUNCTION(BlueprintCallable, BlueprintPure, BlueprintNativeEvent, Category="GCS")
EGCS_AttackResultProcessorPolicy GetExecutePolicy() const;
#if WITH_EDITOR
bool GetEditorEnableState() const { return bEditorDebugEnabled; };
#endif
protected:
/**
* Indicate how this processor will be executed cross network.
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GCS")
EGCS_AttackResultProcessorPolicy ExecutePolicy{EGCS_AttackResultProcessorPolicy::Default};
/**
* Handles the incoming attack result.
* 处理传入的攻击结果。
* @param AttackResult The attack result to handle. 要处理的攻击结果。
*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GCS")
void HandleIncomingAttackResult(const FGCS_AttackResult& AttackResult) const;
virtual void HandleIncomingAttackResult_Implementation(const FGCS_AttackResult& AttackResult) const;
/**
* Gets the owning actor.
* 获取所属演员。
* @return The owning actor. 所属演员。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GCS")
AActor* GetOwningActor() const;
/**
* Gets the owning ability system component.
* 获取所属能力系统组件。
* @return The ability system component. 能力系统组件。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GCS")
UAbilitySystemComponent* GetOwningAbilitySystemComponent() const;
/**
* Gets the editor-friendly name for the processor.
* 获取处理器的编辑器友好名称。
* @return The editor-friendly name. 编辑器友好名称。
*/
UFUNCTION(BlueprintNativeEvent, Category="GCS")
FString GetEditorFriendlyName() const;
virtual FString GetEditorFriendlyName_Implementation() const;
#if WITH_EDITORONLY_DATA
/**
* Allowing toggle on/off this processor for debugging purpose.
* 允许你开关此处理器,用于调试。
*/
UPROPERTY(EditAnywhere, Category="GCS")
bool bEditorDebugEnabled{true};
/**
* Editor-friendly name for the processor.
* 处理器的编辑器友好名称。
*/
UPROPERTY(VisibleAnywhere, Category=AlwaysHidden)
FString EditorFriendlyName;
// UPROPERTY(EditAnywhere, Category="GCS")
// bool bPrintDebugString{false};
/**
* Called before saving in the editor.
* 编辑器中保存前调用。
* @param SaveContext The save context. 保存上下文。
*/
virtual void PreSave(FObjectPreSaveContext SaveContext) override;
#endif
};
/**
* Attack result processor with tag requirements.
* 具有标签要求的攻击结果处理器。
*/
UCLASS(Abstract)
class UGCS_AttackResultProcessor_WithTagRequirement : public UGCS_AttackResultProcessor
{
GENERATED_BODY()
public:
/**
* Processes an incoming attack result with tag requirements.
* 处理具有标签要求的传入攻击结果。
* @param AttackResult The attack result to process. 要处理的攻击结果。
*/
virtual bool ProcessIncomingAttackResult(const FGCS_AttackResult& AttackResult) override;
protected:
/**
* Source tag query for filtering attack results.
* 用于过滤攻击结果的来源标签查询。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GCS")
FGameplayTagQuery SourceTagQuery;
/**
* Target tag query for filtering attack results.
* 用于过滤攻击结果的目标标签查询。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GCS")
FGameplayTagQuery TargetTagQuery;
/**
* Gets the description of the source tag query.
* 获取来源标签查询的描述。
* @return The source tag query description. 来源标签查询描述。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GCS")
FString GetSourceTagQueryDesc() const;
/**
* Gets the description of the target tag query.
* 获取目标标签查询的描述。
* @return The target tag query description. 目标标签查询描述。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GCS")
FString GetTargetTagQueryDesc() const;
};
/**
* Processor for handling death-related attack results.
* 处理与死亡相关的攻击结果的处理器。
*/
UCLASS()
class UGCS_AttackResultProcessor_Death : public UGCS_AttackResultProcessor
{
GENERATED_BODY()
public:
/**
* Handles death-related attack results.
* 处理与死亡相关的攻击结果。
* @param AttackResult The attack result to handle. 要处理的攻击结果。
*/
virtual void HandleIncomingAttackResult_Implementation(const FGCS_AttackResult& AttackResult) const override;
};
/**
* Processor for converting attack results to gameplay events.
* 将攻击结果转换为游戏事件的处理器。
* @note Only executes for server pawn or local controller pawn. The dynamic tags added to effect context will be merged as Instigator Tags.
* @注意 仅对服务器Pawn或本地控制器Pawn执行。 添加到Effect Context的动态标签会被合并为Instigator Tags。
*/
UCLASS()
class UGCS_AttackResultProcessor_GameplayEvent : public UGCS_AttackResultProcessor_WithTagRequirement
{
GENERATED_BODY()
protected:
/**
* Handles attack results by converting to gameplay events.
* 通过转换为游戏事件处理攻击结果。
* @param AttackResult The attack result to handle. 要处理的攻击结果。
*/
virtual void HandleIncomingAttackResult_Implementation(const FGCS_AttackResult& AttackResult) const override;
/**
* Gets the editor-friendly name for the processor.
* 获取处理器的编辑器友好名称。
* @return The editor-friendly name. 编辑器友好名称。
*/
virtual FString GetEditorFriendlyName_Implementation() const override;
/**
* Whether to send the event to the attacker.
* 是否将事件发送给攻击者。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GCS")
bool bSendToAttacker{false};
/**
* Gameplay tags to trigger as events.
* 作为事件触发的游戏标签。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GCS")
TArray<FGameplayTag> EventTriggers;
};
/**
* Processor for triggering gameplay cues from attack results.
* 从攻击结果触发游戏反馈的处理器。
* @note Cues do not replicate as attack results are replicated.
* @注意 反馈不复制,因为攻击结果已复制。
*/
UCLASS()
class UGCS_AttackResultProcessor_GameplayCue : public UGCS_AttackResultProcessor_WithTagRequirement
{
GENERATED_BODY()
protected:
/**
* Handles attack results by triggering gameplay cues.
* 通过触发游戏反馈处理攻击结果。
* @param AttackResult The attack result to handle. 要处理的攻击结果。
*/
virtual void HandleIncomingAttackResult_Implementation(const FGCS_AttackResult& AttackResult) const override;
/**
* Gets the editor-friendly name for the processor.
* 获取处理器的编辑器友好名称。
* @return The editor-friendly name. 编辑器友好名称。
*/
virtual FString GetEditorFriendlyName_Implementation() const override;
/**
* Modifies gameplay cue parameters before execution.
* 在执行前修改游戏反馈参数。
* @param ParametersToModify The parameters to modify. 要修改的参数。
*/
UFUNCTION(BlueprintImplementableEvent, Category="GCS")
void ModifyGameplayCueParametersBeforeExecute(UPARAM(ref)
FGameplayCueParameters& ParametersToModify) const;
/**
* Gameplay cues to trigger.
* 要触发的游戏反馈。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GCS", meta=(Categories="GameplayCue"))
TArray<FGameplayTag> GameplayCues;
/**
* Tag for finding raw magnitude in TaggedValues.
* 在TaggedValues中查找原始幅度的标签。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GCS")
FGameplayTag RawMagnitudeTag;
/**
* Tag for finding normalized magnitude in TaggedValues.
* 在TaggedValues中查找归一化幅度的标签。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="GCS")
FGameplayTag NormalizedMagnitudeTag;
};

View File

@@ -0,0 +1,114 @@
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameplayTagContainer.h"
#include "GCS_ActorOwnedObject.h"
#include "GCS_AttackResult.h"
#include "GGA_GameplayAttributeStructLibrary.h"
#include "GCS_CombatFlow.generated.h"
class UGCS_AttackResultProcessor;
class UGCS_CombatSystemComponent;
/**
* Combat flow for processing incoming attacks.
* 处理传入攻击的战斗流程。
* @note Typically one instance per character type (e.g., human, quadruped, mechanical).
* @注意 通常每种角色类型一个实例(例如人类、四足动物、机械)。
*/
UCLASS(Abstract, BlueprintType, Blueprintable, DefaultToInstanced, EditInlineNew, CollapseCategories, meta=(DisplayName="GCS Combat Flow"))
class GENERICCOMBATSYSTEM_API UGCS_CombatFlow : public UGCS_ActorOwnedObject
{
GENERATED_BODY()
public:
/**
* Default constructor.
* 默认构造函数。
*/
UGCS_CombatFlow();
/**
* Retrieves lifetime replicated properties.
* 获取生命周期复制属性。
* @param OutLifetimeProps The lifetime properties. 生命周期属性。
*/
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
/**
* Checks if networking is supported.
* 检查是否支持网络。
* @return True if supported. 如果支持返回true。
*/
virtual bool IsSupportedForNetworking() const override { return true; }
/**
* Gets the actor owning this combat flow.
* 获取拥有此战斗流程的演员。
* @return The owning actor. 所属演员。
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GCS|Combat Flow")
AActor* GetFlowOwner() const { return Owner; }
/**
* Initializes the combat flow with an owner.
* 使用拥有者初始化战斗流程。
* @param NewOwner The owning actor. 所属演员。
*/
void Initialize(AActor* NewOwner);
/**
* Adds dynamic tags to a gameplay effect spec.
* 为游戏效果规格添加动态标签。
* @note Requires GGA_AbilitySystemGlobals as default AbilitySystemGlobals.
* @注意 需要将GGA_AbilitySystemGlobals设置为默认AbilitySystemGlobals。
* @param Spec The gameplay effect spec. 游戏效果规格。
* @param AbilitySystemComponent The ability system component. 能力系统组件。
* @param OutDynamicTagsAppendToSpec The tags to append (output). 要附加的标签(输出)。
*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GCS|Combat Flow")
void HandlePreGameplayEffectSpecApply(const FGameplayEffectSpec& Spec, UAbilitySystemComponent* AbilitySystemComponent, FGameplayTagContainer& OutDynamicTagsAppendToSpec);
/**
* Handles gameplay effect execution.
* 处理游戏效果执行。
* @param Payload The effect modification data. 效果修改数据。
*/
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GCS|Combat Flow")
void HandleGameplayEffectExecute(const FGGA_GameplayEffectModCallbackData& Payload);
virtual void HandleGameplayEffectExecute_Implementation(const FGGA_GameplayEffectModCallbackData& Payload);
/**
* Handles attack results across the network.
* 在网络上处理攻击结果。
* @note Default implementation calls result processors.
* @注意 默认实现调用结果处理器。
* @param Payload The attack result. 攻击结果。
*/
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "GCS|Combat Flow")
void HandleAttackResult(const FGCS_AttackResult& Payload);
protected:
/**
* The actor owning this combat flow.
* 拥有此战斗流程的演员。
*/
UPROPERTY()
TObjectPtr<AActor> Owner;
/**
* Reference to the owning combat system component.
* 所属战斗系统组件的引用。
*/
UPROPERTY(BlueprintReadOnly, Category = "GCS|Combat Flow", meta=(BlueprintProtected))
TObjectPtr<UGCS_CombatSystemComponent> CombatComponent;
/**
* List of attack result processors for handling attack results.
* 处理攻击结果的攻击结果处理器列表。
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Instanced, Category = "GCS|Combat Flow Settings", meta=(TitleProperty="EditorFriendlyName"))
TArray<TObjectPtr<UGCS_AttackResultProcessor>> AttackResultProcessors;
};