第一次提交
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GCS_CombatTeamAgentInterface.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "GCS_CombatTeamAgentComponent.generated.h"
|
||||
|
||||
/**
|
||||
* Component for managing combat team affiliations.
|
||||
* 管理战斗队伍归属的组件。
|
||||
*/
|
||||
UCLASS(ClassGroup=(GCS), meta=(BlueprintSpawnableComponent), AutoExpandCategories=(GCS))
|
||||
class GENERICCOMBATSYSTEM_API UGCS_CombatTeamAgentComponent : public UActorComponent, public IGCS_CombatTeamAgentInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor.
|
||||
* 默认构造函数。
|
||||
*/
|
||||
UGCS_CombatTeamAgentComponent();
|
||||
|
||||
/**
|
||||
* Retrieves lifetime replicated properties.
|
||||
* 获取生命周期复制属性。
|
||||
* @param OutLifetimeProps The lifetime properties. 生命周期属性。
|
||||
*/
|
||||
virtual void GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const override;
|
||||
|
||||
/**
|
||||
* Gets the delegate for team ID changes.
|
||||
* 获取队伍ID更改的委托。
|
||||
* @return The team ID changed delegate. 队伍ID更改委托。
|
||||
*/
|
||||
virtual FGCS_CombatTeamIdChangedSignature* GetOnTeamIdChangedDelegate() override;
|
||||
|
||||
/**
|
||||
* Gets the current combat team ID.
|
||||
* 获取当前战斗队伍ID。
|
||||
* @return The combat team ID. 战斗队伍ID。
|
||||
*/
|
||||
virtual FGenericTeamId GetCombatTeamId_Implementation() const override;
|
||||
|
||||
/**
|
||||
* Sets the combat team ID.
|
||||
* 设置战斗队伍ID。
|
||||
* @param NewTeamId The new team ID. 新队伍ID。
|
||||
*/
|
||||
virtual void SetCombatTeamId_Implementation(FGenericTeamId NewTeamId) override;
|
||||
|
||||
/**
|
||||
* Handles replication of the combat team ID.
|
||||
* 处理战斗队伍ID的复制。
|
||||
* @param OldTeamID The previous team ID. 旧队伍ID。
|
||||
*/
|
||||
UFUNCTION()
|
||||
void OnRep_CombatTeamId(FGenericTeamId OldTeamID);
|
||||
|
||||
/**
|
||||
* Delegate for team ID change events.
|
||||
* 队伍ID更改事件的委托。
|
||||
*/
|
||||
UPROPERTY(BlueprintAssignable, Category="GCS")
|
||||
FGCS_CombatTeamIdChangedSignature OnTeamIdChangedEvent;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Called when the game starts.
|
||||
* 游戏开始时调用。
|
||||
*/
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
/**
|
||||
* The current team ID of this agent.
|
||||
* 此代理的当前队伍ID。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category="GCS", ReplicatedUsing=OnRep_CombatTeamId)
|
||||
FGenericTeamId CombatTeamId;
|
||||
|
||||
/**
|
||||
* Whether to assign the team ID to the controller.
|
||||
* 是否将队伍ID分配给控制器。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category="GCS")
|
||||
bool bAssignTeamIdToController{true};
|
||||
|
||||
public:
|
||||
/**
|
||||
* Called every frame.
|
||||
* 每帧调用。
|
||||
* @param DeltaTime Time since last frame. 上一帧以来的时间。
|
||||
* @param TickType The type of tick. tick类型。
|
||||
* @param ThisTickFunction The tick function. tick函数。
|
||||
*/
|
||||
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GenericTeamAgentInterface.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "GCS_CombatTeamAgentInterface.generated.h"
|
||||
|
||||
/**
|
||||
* Delegate for team ID change events.
|
||||
* 队伍ID更改事件的委托。
|
||||
*/
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FGCS_CombatTeamIdChangedSignature, UObject*, ObjectChangingTeam, FGenericTeamId, OldTeamID, FGenericTeamId, NewTeamID);
|
||||
|
||||
/**
|
||||
* Interface for combat team agents.
|
||||
* 战斗队伍代理的接口。
|
||||
*/
|
||||
UINTERFACE(MinimalAPI, BlueprintType, Blueprintable)
|
||||
class UGCS_CombatTeamAgentInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface for managing combat team affiliations.
|
||||
* 管理战斗队伍归属的接口。
|
||||
*/
|
||||
class GENERICCOMBATSYSTEM_API IGCS_CombatTeamAgentInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Sets the combat team ID.
|
||||
* 设置战斗队伍ID。
|
||||
* @note Default implementation converts to GenericTeamAgentInterface.
|
||||
* @注意 默认实现转换为GenericTeamAgentInterface。
|
||||
* @param NewTeamId The new team ID. 新队伍ID。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GCS|CombatTeam")
|
||||
void SetCombatTeamId(FGenericTeamId NewTeamId);
|
||||
virtual void SetCombatTeamId_Implementation(FGenericTeamId NewTeamId);
|
||||
|
||||
/**
|
||||
* Gets the current combat team ID.
|
||||
* 获取当前战斗队伍ID。
|
||||
* @return The combat team ID. 战斗队伍ID。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="GCS|CombatTeam")
|
||||
FGenericTeamId GetCombatTeamId() const;
|
||||
virtual FGenericTeamId GetCombatTeamId_Implementation() const;
|
||||
|
||||
/**
|
||||
* Gets the delegate for team ID changes.
|
||||
* 获取队伍ID更改的委托。
|
||||
* @return The team ID changed delegate. 队伍ID更改委托。
|
||||
*/
|
||||
virtual FGCS_CombatTeamIdChangedSignature* GetOnTeamIdChangedDelegate() = 0;
|
||||
|
||||
/**
|
||||
* Conditionally broadcasts team change events.
|
||||
* 有条件地广播队伍更改事件。
|
||||
* @param This The combat team agent interface. 战斗队伍代理接口。
|
||||
* @param OldTeamID The previous team ID. 旧队伍ID。
|
||||
* @param NewTeamID The new team ID. 新队伍ID。
|
||||
*/
|
||||
static void ConditionalBroadcastTeamChanged(TScriptInterface<IGCS_CombatTeamAgentInterface> This, FGenericTeamId OldTeamID, FGenericTeamId NewTeamID);
|
||||
|
||||
/**
|
||||
* Gets the team changed delegate with validation.
|
||||
* 获取经过验证的队伍更改委托。
|
||||
* @return The team changed delegate. 队伍更改委托。
|
||||
*/
|
||||
FGCS_CombatTeamIdChangedSignature& GetTeamChangedDelegateChecked()
|
||||
{
|
||||
FGCS_CombatTeamIdChangedSignature* Result = GetOnTeamIdChangedDelegate();
|
||||
check(Result);
|
||||
return *Result;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user