MassBattle Docsv1.19.20

FFCPathingAsyncAction.h

UCLASS ×2

Source/FlowFieldCanvas/Public/FFCPathingAsyncAction.h

概述 Overview

蓝图异步节点文件,把 FlowFieldCanvas 的移动能力封装成「AI Move To」风格的延迟执行节点。两个节点:UFFCMoveToFlowFieldGoal——跟随流场方向直至其目标;UFFCMoveTo——向目标 Actor 或目标位置做个体寻路。节点在 Activate() 中为目标 Actor 获取或新建 UFFCPathingComponent(找不到就 NewObject + RegisterComponent),绑定其 OnSuccess / OnFailed,启动移动;完成后解绑、广播 OnSuccess / OnFailed 输出引脚并 SetReadyToDestroy。

Blueprint async node file wrapping FlowFieldCanvas movement into "AI Move To"-style latent nodes. Two nodes: UFFCMoveToFlowFieldGoal — follows the flow field direction to its goal; UFFCMoveTo — individual pathfinding toward a goal actor or goal location. In Activate() each node finds or creates a UFFCPathingComponent on the target actor (NewObject + RegisterComponent when missing), binds its OnSuccess / OnFailed, and starts movement; on completion it unbinds, broadcasts the OnSuccess / OnFailed output pins, and calls SetReadyToDestroy.

UFFCMoveToFlowFieldGoal UCLASS

「FFC Move To Flow Field Goal」节点:让 Actor 沿流场方向移动到流场目标。与 AI Move To 类似,带成功/失败输出。超时(秒,0 = 无限)与到达半径可配。

The "FFC Move To Flow Field Goal" node: moves an actor along the flow field directions until it reaches the field's goal. Similar to AI Move To with success/failed outputs. Timeout (seconds, 0 = none) and acceptance radius are configurable.

继承 Inheritance

UBlueprintAsyncActionBase → UFFCMoveToFlowFieldGoal

公开方法 Public Methods

MoveToFlowFieldGoal static UFFCMoveToFlowFieldGoal* (UObject* WorldContext, AActor* Actor, AFlowField* FlowField, float AcceptanceRadius, float Timeout)

节点工厂:创建动作对象,记录目标 Actor、流场、接受半径与超时,RegisterWithGameInstance(WorldContext) 后返回。蓝图侧标记 BlueprintInternalUseOnly 与 DefaultToSelf = "WorldContext"。

Node factory: creates the action object, stores the target actor, flow field, acceptance radius and timeout, calls RegisterWithGameInstance(WorldContext), and returns it. Blueprint-side marked BlueprintInternalUseOnly and DefaultToSelf = "WorldContext".

Input
参数 Param类型 Type说明 Description
WorldContextUObject*世界上下文,用于注册到 GameInstance。World context, used to register with the game instance.
ActorAActor*要移动的 Actor(将获取/添加 UFFCPathingComponent)。The actor to move (will get/add UFFCPathingComponent).
FlowFieldAFlowField*要跟随的流场。The flow field to follow.
AcceptanceRadiusfloat判定成功到达目标的距离,默认 50.0。Distance from the goal at which movement is considered successful; default 50.0.
Timeoutfloat最大时长(秒),0 = 无超时。Maximum time in seconds; 0 = no timeout.
Output

返回动作对象(带 OnSuccess/OnFailed 输出的异步节点)。

Returns the async action (a latent node with OnSuccess/OnFailed outputs).

Activate virtual void

节点启动(自动调用):① 目标 Actor 或流场无效 → 广播 OnFailed 并销毁;② FindComponentByClass<UFFCPathingComponent> 查找,找不到则 NewObject(RF_Transient)+ RegisterComponent;③ 仍拿不到组件 → 广播失败并销毁;④ 绑定组件 OnSuccess / OnFailed 到 HandleSuccess / HandleFailed;⑤ 设置流场与接受半径,调用 StartFlowFieldFollowing(StoredTimeout)。

Node activation (called automatically): ① invalid target actor or flow field → broadcast OnFailed and destroy; ② FindComponentByClass<UFFCPathingComponent>, creating one via NewObject (RF_Transient) + RegisterComponent when missing; ③ still no component → broadcast failure and destroy; ④ binds the component's OnSuccess / OnFailed to HandleSuccess / HandleFailed; ⑤ sets the flow field and acceptance radius, then calls StartFlowFieldFollowing(StoredTimeout).

Input

无参数。

No parameters.

Output

无返回值。副作用:为 Actor 添加/复用 PathingComponent 并启动移动;失败路径立即广播并销毁。

No return value. Side effects: adds/reuses a PathingComponent on the actor and starts movement; failure paths broadcast and destroy immediately.

HandleSuccess private UFUNCTION void

组件成功回调:先 Cleanup() 解绑,再广播 OnSuccess,最后 SetReadyToDestroy。

Component success callback: Cleanup() to unbind, then broadcast OnSuccess, then SetReadyToDestroy.

Input

无参数。

No parameters.

Output

无返回值。副作用:解绑组件委托、广播输出引脚、标记销毁。

No return value. Side effects: unbinds the component delegates, broadcasts the output pin, and marks for destruction.

HandleFailed private UFUNCTION void

组件失败回调(超时、丢失流场、无效 Actor 等):Cleanup() 解绑 → 广播 OnFailed → SetReadyToDestroy。

Component failure callback (timeout, lost flow field, invalid actor, etc.): Cleanup() to unbind → broadcast OnFailed → SetReadyToDestroy.

Input

无参数。

No parameters.

Output

无返回值。副作用:解绑组件委托、广播输出引脚、标记销毁。

No return value. Side effects: unbinds the component delegates, broadcasts the output pin, and marks for destruction.

Cleanup private void

从组件的 OnSuccess / OnFailed 移除本对象的两个动态绑定。

Removes this object's two dynamic bindings from the component's OnSuccess / OnFailed.

Input

无参数。

No parameters.

Output

无返回值。副作用:解绑动态委托(组件仍有效时)。

No return value. Side effect: unbinds the dynamic delegates (when the component is still valid).

成员变量 Members

名称 Name类型 Type默认值说明 Description
OnSuccessFFFCAsyncDelegate (BlueprintAssignable)—Actor 到达流场目标时触发。Fires when the actor reaches the flow field goal.
OnFailedFFFCAsyncDelegate (BlueprintAssignable)—移动失败时触发(超时、丢失流场、无效 Actor 等)。Fires when movement fails (timeout, lost flow field, invalid actor, etc.).
TargetActorTWeakObjectPtr<AActor> (private)—要移动的 Actor 弱引用。Weak reference to the actor to move.
TargetFlowFieldTWeakObjectPtr<AFlowField> (private)—目标流场弱引用。Weak reference to the target flow field.
PathingComponentTWeakObjectPtr<UFFCPathingComponent> (private)—驱动移动的组件弱引用。Weak reference to the driving pathing component.
StoredAcceptanceRadiusfloat (private)50.0f工厂入参保存的到达半径。Acceptance radius saved from the factory input.
StoredTimeoutfloat (private)0.0f工厂入参保存的超时。Timeout saved from the factory input.

UFFCMoveTo UCLASS

「FFC Move To」节点:向目标(Actor 或位置)做个体寻路。与 AI Move To 类似——设置了 GoalActor 时朝 Actor 移动(随其移动更新路径),否则朝 GoalLocation 移动;按组件设置用 NavMesh 或 Grid A*。目标 Actor 优先于目标位置。

The "FFC Move To" node: individual pathfinding to a goal (actor or location). Similar to AI Move To — with GoalActor set it moves toward that actor (updating the path as it moves), otherwise toward GoalLocation; uses NavMesh or Grid A* per the component settings. The goal actor takes priority over the goal location.

继承 Inheritance

UBlueprintAsyncActionBase → UFFCMoveTo

公开方法 Public Methods

MoveTo static UFFCMoveTo* (UObject* WorldContext, AActor* Actor, AFlowField* FlowField, AActor* GoalActor, FVector GoalLocation, float AcceptanceRadius, float Timeout)

节点工厂:创建动作对象并保存全部入参,RegisterWithGameInstance(WorldContext) 后返回。蓝图侧 BlueprintInternalUseOnly、DefaultToSelf = "WorldContext",GoalLocation 为高级显示参数。

Node factory: creates the action object, stores all inputs, calls RegisterWithGameInstance(WorldContext), and returns. Blueprint-side BlueprintInternalUseOnly, DefaultToSelf = "WorldContext", with GoalLocation as an advanced-display parameter.

Input
参数 Param类型 Type说明 Description
WorldContextUObject*世界上下文。World context.
ActorAActor*要移动的 Actor(将获取/添加 UFFCPathingComponent)。The actor to move (will get/add UFFCPathingComponent).
FlowFieldAFlowField*用于寻路查询的流场。The flow field used for pathfinding queries.
GoalActorAActor*目标 Actor(可选,优先于 GoalLocation)。Target actor (optional; takes priority over GoalLocation).
GoalLocationFVector目标世界位置(GoalActor 为 null 时使用)。Target world location (used when GoalActor is null).
AcceptanceRadiusfloat判定成功到达的距离,默认 50.0。Distance at which movement is considered successful; default 50.0.
Timeoutfloat最大时长(秒),0 = 无超时。Maximum time in seconds; 0 = no timeout.
Output

返回动作对象(带 OnSuccess/OnFailed 输出的异步节点)。

Returns the async action (a latent node with OnSuccess/OnFailed outputs).

Activate virtual void

节点启动(自动调用):① 目标 Actor 或流场无效,或既无目标 Actor 又 GoalLocation 为零向量 → 广播失败并销毁;② 获取/新建 PathingComponent(同上);③ 绑定委托、设置流场与接受半径;④ 有目标 Actor 则 StartPathFollowingActor,否则 StartPathFollowing;⑤ 按结果分支:Success 等待回调;AlreadyAtGoal → 解绑、广播成功、销毁;NoFlowField / Failed → 解绑、广播失败、销毁。

Node activation (called automatically): ① invalid target actor or flow field, or neither a goal actor nor a non-zero GoalLocation → broadcast failure and destroy; ② finds/creates the PathingComponent (as above); ③ binds delegates, sets the flow field and acceptance radius; ④ calls StartPathFollowingActor with a goal actor, otherwise StartPathFollowing; ⑤ branches on the result: Success waits for the callback; AlreadyAtGoal → unbind, broadcast success, destroy; NoFlowField / Failed → unbind, broadcast failure, destroy.

Input

无参数。

No parameters.

Output

无返回值。副作用:为 Actor 添加/复用 PathingComponent 并启动移动;即时失败/已在目标时立即广播并销毁。

No return value. Side effects: adds/reuses a PathingComponent on the actor and starts movement; immediate-failure and already-at-goal paths broadcast and destroy right away.

HandleSuccess private UFUNCTION void

组件成功回调:Cleanup() 解绑 → 广播 OnSuccess → SetReadyToDestroy。

Component success callback: Cleanup() to unbind → broadcast OnSuccess → SetReadyToDestroy.

Input

无参数。

No parameters.

Output

无返回值。副作用:解绑、广播、标记销毁。

No return value. Side effects: unbind, broadcast, mark for destruction.

HandleFailed private UFUNCTION void

组件失败回调(无路径、超时、无效 Actor 等):Cleanup() 解绑 → 广播 OnFailed → SetReadyToDestroy。

Component failure callback (no path, timeout, invalid actor, etc.): Cleanup() to unbind → broadcast OnFailed → SetReadyToDestroy.

Input

无参数。

No parameters.

Output

无返回值。副作用:解绑、广播、标记销毁。

No return value. Side effects: unbind, broadcast, mark for destruction.

Cleanup private void

从组件的 OnSuccess / OnFailed 移除本对象的两个动态绑定。

Removes this object's two dynamic bindings from the component's OnSuccess / OnFailed.

Input

无参数。

No parameters.

Output

无返回值。副作用:解绑动态委托。

No return value. Side effect: unbinds the dynamic delegates.

GetCurrentGoalLocation private FVector const

返回当前目标位置:追踪 Actor 时返回其当前位置,否则返回存储的目标位置。

Returns the current goal location: the goal actor's current location when tracking one, otherwise the stored location.

Input

无参数。

No parameters.

Output

返回目标位置向量。

Returns the goal location vector.

成员变量 Members

名称 Name类型 Type默认值说明 Description
OnSuccessFFFCAsyncDelegate (BlueprintAssignable)—Actor 到达目标时触发。Fires when the actor reaches the goal.
OnFailedFFFCAsyncDelegate (BlueprintAssignable)—移动失败时触发(无路径、超时、无效 Actor 等)。Fires when movement fails (no path, timeout, invalid actor, etc.).
TargetActorTWeakObjectPtr<AActor> (private)—要移动的 Actor 弱引用。Weak reference to the actor to move.
TargetFlowFieldTWeakObjectPtr<AFlowField> (private)—目标流场弱引用。Weak reference to the target flow field.
GoalActorTWeakObjectPtr<AActor> (private)—目标 Actor 弱引用(优先于存储位置)。Weak reference to the goal actor (takes priority over the stored location).
PathingComponentTWeakObjectPtr<UFFCPathingComponent> (private)—驱动移动的组件弱引用。Weak reference to the driving pathing component.
StoredGoalLocationFVector (private)ZeroVector工厂入参保存的目标位置。Goal location saved from the factory input.
StoredAcceptanceRadiusfloat (private)50.0f工厂入参保存的到达半径。Acceptance radius saved from the factory input.
StoredTimeoutfloat (private)0.0f工厂入参保存的超时。Timeout saved from the factory input.

管线角色 Pipeline Role

两个节点是 UFFCPathingComponent 的蓝图驱动层:工厂方法保存入参并注册到 GameInstance,Activate() 中获取/新建组件并绑定 OnSuccess / OnFailed,调用 StartFlowFieldFollowing / StartPathFollowing / StartPathFollowingActor;组件每帧 tick 移动,到达或失败后广播委托,节点回调 HandleSuccess / HandleFailed 解绑并销毁。底层寻路调用 AFlowField 的查询与寻路 API(QueryNavigationAdvanced / FindPathNavMesh / FindPathAStar / GetSteeringDirection)。

The two nodes are the blueprint driver layer of UFFCPathingComponent: the factories store inputs and register with the game instance; Activate() finds/creates the component, binds OnSuccess / OnFailed, and calls StartFlowFieldFollowing / StartPathFollowing / StartPathFollowingActor; the component moves each tick and broadcasts on arrival/failure, where the nodes' HandleSuccess / HandleFailed unbind and destroy. Underlying pathfinding calls AFlowField's query and pathfinding APIs (QueryNavigationAdvanced / FindPathNavMesh / FindPathAStar / GetSteeringDirection).