You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Removed unnecessary checks for specific transition (handled in enter state logic) - Added state type to StateTreeState, State, Group, or Linked - StateTreeState property customization hides properties based on type - Allow a state to link to another state - Changed baker binding validation to handle linked states - Added linked state handling in execution context - Updated UI deal with linked states - Updated gameplay debugger to deal with linked states - Moved automatic Root state adding from Editor data to editor open (tests were broken due to extra root state) - Fixed tests and added simple test for linked state - Added meta to tag to state link to allow to select only direct states (no next, etc) - Added counter to track state changes (mainly for debugging) #jira UE-147509 #review #preflight 624beb69637925b5d306d8e7 [CL 19621621 by mikko mononen in ue5-main branch]
90 lines
3.8 KiB
C++
90 lines
3.8 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Blueprint/StateTreeTaskBlueprintBase.h"
|
|
#include "CoreMinimal.h"
|
|
#include "StateTreeExecutionContext.h"
|
|
|
|
//----------------------------------------------------------------------//
|
|
// UStateTreeTaskBlueprintBase
|
|
//----------------------------------------------------------------------//
|
|
|
|
EStateTreeRunStatus UStateTreeTaskBlueprintBase::ReceiveEnterState_Implementation(AActor* OwnerActor, const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition)
|
|
{
|
|
return EStateTreeRunStatus::Running;
|
|
}
|
|
|
|
EStateTreeRunStatus UStateTreeTaskBlueprintBase::EnterState(FStateTreeExecutionContext& Context, const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition)
|
|
{
|
|
AActor* OwnerActor = GetOwnerActor(Context);
|
|
return ReceiveEnterState(OwnerActor, ChangeType, Transition);
|
|
}
|
|
|
|
void UStateTreeTaskBlueprintBase::ExitState(FStateTreeExecutionContext& Context, const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition)
|
|
{
|
|
AActor* OwnerActor = GetOwnerActor(Context);
|
|
ReceiveExitState(OwnerActor, ChangeType, Transition);
|
|
}
|
|
|
|
void UStateTreeTaskBlueprintBase::StateCompleted(FStateTreeExecutionContext& Context, const EStateTreeRunStatus CompletionStatus, const FStateTreeActiveStates& CompletedActiveStates)
|
|
{
|
|
AActor* OwnerActor = GetOwnerActor(Context);
|
|
ReceiveStateCompleted(OwnerActor, CompletionStatus, CompletedActiveStates);
|
|
}
|
|
|
|
EStateTreeRunStatus UStateTreeTaskBlueprintBase::Tick(FStateTreeExecutionContext& Context, const float DeltaTime)
|
|
{
|
|
AActor* OwnerActor = GetOwnerActor(Context);
|
|
return ReceiveTick(OwnerActor, DeltaTime);
|
|
}
|
|
|
|
//----------------------------------------------------------------------//
|
|
// FStateTreeBlueprintTaskWrapper
|
|
//----------------------------------------------------------------------//
|
|
|
|
bool FStateTreeBlueprintTaskWrapper::Link(FStateTreeLinker& Linker)
|
|
{
|
|
const UStateTreeTaskBlueprintBase* TaskCDO = TaskClass ? TaskClass->GetDefaultObject<UStateTreeTaskBlueprintBase>() : nullptr;
|
|
if (TaskCDO != nullptr)
|
|
{
|
|
TaskCDO->LinkExternalData(Linker, ExternalDataHandles);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
EStateTreeRunStatus FStateTreeBlueprintTaskWrapper::EnterState(FStateTreeExecutionContext& Context, const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition) const
|
|
{
|
|
UStateTreeTaskBlueprintBase* Instance = Context.GetInstanceObjectInternal<UStateTreeTaskBlueprintBase>(DataViewIndex);
|
|
check(Instance);
|
|
|
|
Instance->CopyExternalData(Context, ExternalDataHandles);
|
|
return Instance->EnterState(Context, ChangeType, Transition);
|
|
}
|
|
|
|
void FStateTreeBlueprintTaskWrapper::ExitState(FStateTreeExecutionContext& Context, const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition) const
|
|
{
|
|
UStateTreeTaskBlueprintBase* Instance = Context.GetInstanceObjectInternal<UStateTreeTaskBlueprintBase>(DataViewIndex);
|
|
check(Instance);
|
|
|
|
Instance->CopyExternalData(Context, ExternalDataHandles);
|
|
Instance->ExitState(Context, ChangeType, Transition);
|
|
}
|
|
|
|
void FStateTreeBlueprintTaskWrapper::StateCompleted(FStateTreeExecutionContext& Context, const EStateTreeRunStatus CompletionStatus, const FStateTreeActiveStates& CompletedActiveStates) const
|
|
{
|
|
UStateTreeTaskBlueprintBase* Instance = Context.GetInstanceObjectInternal<UStateTreeTaskBlueprintBase>(DataViewIndex);
|
|
check(Instance);
|
|
|
|
Instance->CopyExternalData(Context, ExternalDataHandles);
|
|
Instance->StateCompleted(Context, CompletionStatus, CompletedActiveStates);
|
|
}
|
|
|
|
EStateTreeRunStatus FStateTreeBlueprintTaskWrapper::Tick(FStateTreeExecutionContext& Context, const float DeltaTime) const
|
|
{
|
|
UStateTreeTaskBlueprintBase* Instance = Context.GetInstanceObjectInternal<UStateTreeTaskBlueprintBase>(DataViewIndex);
|
|
check(Instance);
|
|
|
|
Instance->CopyExternalData(Context, ExternalDataHandles);
|
|
return Instance->Tick(Context, DeltaTime);
|
|
}
|