StateTree: Improved event handling

- 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]
This commit is contained in:
mikko mononen
2022-11-01 15:11:19 -04:00
parent 4ab49b8c5d
commit 186e03b32e
18 changed files with 287 additions and 99 deletions
@@ -39,7 +39,9 @@ protected:
* Note: The API has been deprecated. ChangeType is moved into FStateTreeTransitionResult.
* You can configure the task to be only called on state changes (that is, never call sustained changes) by setting bShouldStateChangeOnReselect to true.
*/
UE_DEPRECATED(5.2, "Use EnterState without ChangeType instead.")
virtual EStateTreeRunStatus EnterState(FStateTreeExecutionContext& Context, const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition) final { return EStateTreeRunStatus::Running; }
UE_DEPRECATED(5.2, "Use ExitState without ChangeType instead.")
virtual void ExitState(FStateTreeExecutionContext& Context, const EStateTreeStateChangeType ChangeType, const FStateTreeTransitionResult& Transition) final {};
virtual EStateTreeRunStatus EnterState(FStateTreeExecutionContext& Context, const FStateTreeTransitionResult& Transition);
@@ -53,7 +55,11 @@ protected:
* Generally this should be true for action type tasks, like playing animation,
* and false on state like tasks like claiming a resource that is expected to be acquired on child states. */
UPROPERTY(EditDefaultsOnly, Category="Default")
bool bShouldStateChangeOnReselect = true;
uint8 bShouldStateChangeOnReselect : 1;
/** If set to true, Tick() is called. Default false. */
UPROPERTY(EditDefaultsOnly, Category="Default")
uint8 bShouldCallTickOnlyOnEvents : 1;
uint8 bHasEnterState : 1;
uint8 bHasExitState : 1;