You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Moved event queue to it's own struct - Changed the SendEvent() API to accept struct view to prevent instanced struct copy in common cases - Fixed event handling in case EnterState() fails. - Added option for Tasks to disavble ticking, or to be ticked only when there are events - Added option for Tasks handle when properties are copied - Changed DebugText to use external Actor reference - Changed DelayTask to use the new GetInstanceData which does not need type - Added TStateTreeInstanceDataStructRef which can be used to access struct instance data in delegates #rb Maxime.Mercier Luciano.Ferraro #preflight 6360dd302b5338aceb2d0343 [CL 22888708 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
|
|
{
|
|
FInstanceDataType& InstanceData = Context.GetInstanceData(*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
|
|
{
|
|
FInstanceDataType& InstanceData = Context.GetInstanceData(*this);
|
|
|
|
if (!InstanceData.bRunForever)
|
|
{
|
|
InstanceData.RemainingTime -= DeltaTime;
|
|
|
|
if (InstanceData.RemainingTime <= 0.f)
|
|
{
|
|
return EStateTreeRunStatus::Succeeded;
|
|
}
|
|
}
|
|
|
|
return EStateTreeRunStatus::Running;
|
|
}
|
|
|