2021-09-28 13:33:17 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "StateTreeTypes.h"
|
2022-02-03 09:13:49 -05:00
|
|
|
#include "StateTreeNodeBase.h"
|
2021-09-28 13:33:17 -04:00
|
|
|
#include "StateTreeEvaluatorBase.generated.h"
|
|
|
|
|
|
|
|
|
|
struct FStateTreeExecutionContext;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base struct of StateTree Evaluators.
|
|
|
|
|
* Evaluators calculate and expose data to be used for decision making in a StateTree.
|
|
|
|
|
*/
|
|
|
|
|
USTRUCT()
|
2022-02-03 09:13:49 -05:00
|
|
|
struct STATETREEMODULE_API FStateTreeEvaluatorBase : public FStateTreeNodeBase
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when a new state is entered and evaluator is part of active states. The change type parameter describes if the evaluator's state
|
|
|
|
|
* was previously part of the list of active states (Sustained), or if it just became active (Changed).
|
|
|
|
|
* @param Context Reference to current execution context.
|
|
|
|
|
* @param ChangeType Describes the change type (Changed/Sustained).
|
|
|
|
|
* @param Transition Describes the states involved in the transition
|
|
|
|
|
*/
|
2021-11-12 05:48:11 -05:00
|
|
|
virtual void EnterState(FStateTreeExecutionContext& Context, const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition) const {}
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when a current state is exited and evaluator is part of active states. The change type parameter describes if the evaluator's state
|
|
|
|
|
* will be active after the transition (Sustained), or if it will became inactive (Changed).
|
|
|
|
|
* @param Context Reference to current execution context.
|
|
|
|
|
* @param ChangeType Describes the change type (Changed/Sustained).
|
|
|
|
|
* @param Transition Describes the states involved in the transition
|
|
|
|
|
*/
|
2021-11-12 05:48:11 -05:00
|
|
|
virtual void ExitState(FStateTreeExecutionContext& Context, const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition) const {}
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called Right after a state has been completed. StateCompleted is called in reverse order to allow to propagate state to Evaluators and Tasks that
|
|
|
|
|
* are executed earlier in the tree. Note that StateCompleted is not called if conditional transition changes the state.
|
|
|
|
|
* @param Context Reference to current execution context.
|
|
|
|
|
* @param CompletionStatus Describes the running status of the completed state (Succeeded/Failed).
|
2022-04-05 03:20:57 -04:00
|
|
|
* @param CompletedActiveStates Active states at the time of completion.
|
2021-09-28 13:33:17 -04:00
|
|
|
*/
|
2022-04-05 03:20:57 -04:00
|
|
|
virtual void StateCompleted(FStateTreeExecutionContext& Context, const EStateTreeRunStatus CompletionStatus, const FStateTreeActiveStates& CompletedActiveStates) const {}
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when evaluator needs to be updated. EvalType describes if the tick happens during state tree tick when the evaluator is on active state (Tick),
|
|
|
|
|
* or during state selection process when the evaluator's state is visited while it's inactive (PreSelection).
|
|
|
|
|
* That is, type "Tick" means that the call happens between EnterState()/ExitState() pair, "PreSelection" is used otherwise.
|
|
|
|
|
* @param Context Reference to current execution context.
|
|
|
|
|
* @param EvalType Describes tick type.
|
|
|
|
|
* @param DeltaTime Time since last StateTree tick, or 0 if called during preselection.
|
|
|
|
|
*/
|
2021-11-12 05:48:11 -05:00
|
|
|
virtual void Evaluate(FStateTreeExecutionContext& Context, const EStateTreeEvaluationType EvalType, const float DeltaTime) const {}
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
#if WITH_GAMEPLAY_DEBUGGER
|
|
|
|
|
virtual void AppendDebugInfoString(FString& DebugString, const FStateTreeExecutionContext& Context) const;
|
|
|
|
|
#endif // WITH_GAMEPLAY_DEBUGGER
|
|
|
|
|
};
|
2021-12-09 05:38:26 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base class (namespace) for all common Evaluators that are generally applicable.
|
|
|
|
|
* This allows schemas to safely include all Evaluators child of this struct.
|
|
|
|
|
*/
|
|
|
|
|
USTRUCT(Meta=(Hidden))
|
|
|
|
|
struct STATETREEMODULE_API FStateTreeEvaluatorCommonBase : public FStateTreeEvaluatorBase
|
|
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
};
|