2022-05-03 08:30:05 -04:00
|
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include "StateTreeTaskBase.h"
|
|
|
|
|
|
#include "StateTreeDelayTask.generated.h"
|
|
|
|
|
|
|
2023-01-19 00:48:07 -05:00
|
|
|
|
enum class EStateTreeRunStatus : uint8;
|
|
|
|
|
|
struct FStateTreeTransitionResult;
|
|
|
|
|
|
|
2022-05-03 08:30:05 -04:00
|
|
|
|
USTRUCT()
|
|
|
|
|
|
struct STATETREEMODULE_API FStateTreeDelayTaskInstanceData
|
|
|
|
|
|
{
|
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
2022-09-10 00:01:26 -04:00
|
|
|
|
/** Delay before the task ends. */
|
|
|
|
|
|
UPROPERTY(EditAnywhere, Category = Parameter, meta = (EditCondition = "!bRunForever", ClampMin="0.0"))
|
|
|
|
|
|
float Duration = 1.f;
|
|
|
|
|
|
|
|
|
|
|
|
/** Adds random range to the Duration. */
|
|
|
|
|
|
UPROPERTY(EditAnywhere, Category = Parameter, meta = (EditCondition = "!bRunForever", ClampMin="0.0"))
|
|
|
|
|
|
float RandomDeviation = 0.f;
|
|
|
|
|
|
|
|
|
|
|
|
/** If true the task will run forever until a transition stops it. */
|
2022-05-03 08:30:05 -04:00
|
|
|
|
UPROPERTY(EditAnywhere, Category = Parameter)
|
2022-09-10 00:01:26 -04:00
|
|
|
|
bool bRunForever = false;
|
2022-05-03 08:30:05 -04:00
|
|
|
|
|
2022-09-10 00:01:26 -04:00
|
|
|
|
/** Internal countdown in seconds. */
|
|
|
|
|
|
float RemainingTime = 0.f;
|
2022-05-03 08:30:05 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Simple task to wait indefinitely or for a given time (in seconds) before succeeding.
|
|
|
|
|
|
*/
|
|
|
|
|
|
USTRUCT(meta = (DisplayName = "Delay Task"))
|
|
|
|
|
|
struct STATETREEMODULE_API FStateTreeDelayTask : public FStateTreeTaskCommonBase
|
|
|
|
|
|
{
|
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
2022-11-01 15:11:19 -04:00
|
|
|
|
using FInstanceDataType = FStateTreeDelayTaskInstanceData;
|
2022-05-03 08:30:05 -04:00
|
|
|
|
|
|
|
|
|
|
FStateTreeDelayTask() = default;
|
|
|
|
|
|
|
2022-11-01 15:11:19 -04:00
|
|
|
|
virtual const UStruct* GetInstanceDataType() const override { return FInstanceDataType::StaticStruct(); }
|
2022-05-03 08:30:05 -04:00
|
|
|
|
|
2022-09-28 09:55:53 -04:00
|
|
|
|
virtual EStateTreeRunStatus EnterState(FStateTreeExecutionContext& Context, const FStateTreeTransitionResult& Transition) const override;
|
2022-09-10 00:01:26 -04:00
|
|
|
|
virtual EStateTreeRunStatus Tick(FStateTreeExecutionContext& Context, const float DeltaTime) const override;
|
2022-05-03 08:30:05 -04:00
|
|
|
|
};
|