You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Removed change type from EnterState/ExitState and moved it to transition result - Added bShouldStateChangeOnReselect which allows to configure a task to behave more like state - Updated existing tasks #jira UE-156544 #rb Mieszko.Zielinski #preflight 6333f6dca907d7192f5f0ccc [CL 22221382 by mikko mononen in ue5-main branch]
39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "StateTreeDelayTask.h"
|
|
#include "StateTreeExecutionContext.h"
|
|
#include "StateTreeLinker.h"
|
|
|
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(StateTreeDelayTask)
|
|
|
|
EStateTreeRunStatus FStateTreeDelayTask::EnterState(FStateTreeExecutionContext& Context, const FStateTreeTransitionResult& Transition) const
|
|
{
|
|
InstanceDataType& InstanceData = Context.GetInstanceData<InstanceDataType>(*this);
|
|
|
|
if (!InstanceData.bRunForever)
|
|
{
|
|
InstanceData.RemainingTime = FMath::FRandRange(
|
|
FMath::Max(0.0f, InstanceData.Duration - InstanceData.RandomDeviation), (InstanceData.Duration + InstanceData.RandomDeviation));
|
|
}
|
|
|
|
return EStateTreeRunStatus::Running;
|
|
}
|
|
|
|
EStateTreeRunStatus FStateTreeDelayTask::Tick(FStateTreeExecutionContext& Context, const float DeltaTime) const
|
|
{
|
|
InstanceDataType& InstanceData = Context.GetInstanceData<InstanceDataType>(*this);
|
|
|
|
if (!InstanceData.bRunForever)
|
|
{
|
|
InstanceData.RemainingTime -= DeltaTime;
|
|
|
|
if (InstanceData.RemainingTime <= 0.f)
|
|
{
|
|
return EStateTreeRunStatus::Succeeded;
|
|
}
|
|
}
|
|
|
|
return EStateTreeRunStatus::Running;
|
|
}
|
|
|