2023-03-14 13:35:46 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#if WITH_STATETREE_DEBUGGER
|
|
|
|
|
|
|
|
|
|
#include "Trace/Trace.h"
|
|
|
|
|
|
|
|
|
|
class UStateTree;
|
2023-04-19 13:26:23 -04:00
|
|
|
struct FStateTreeDataView;
|
2023-03-14 13:35:46 -04:00
|
|
|
struct FStateTreeActiveStates;
|
|
|
|
|
struct FStateTreeInstanceDebugId;
|
2023-04-19 13:26:23 -04:00
|
|
|
enum class EStateTreeRunStatus : uint8;
|
2023-03-14 13:35:46 -04:00
|
|
|
enum class EStateTreeTraceNodeEventType : uint8;
|
2023-05-09 12:57:56 -04:00
|
|
|
enum class EStateTreeUpdatePhase : uint16;
|
2023-03-14 13:35:46 -04:00
|
|
|
enum class EStateTreeTraceInstanceEventType : uint8;
|
|
|
|
|
|
|
|
|
|
UE_TRACE_CHANNEL_EXTERN(StateTreeDebugChannel, STATETREEMODULE_API)
|
|
|
|
|
|
2023-03-15 11:59:44 -04:00
|
|
|
namespace UE::StateTreeTrace
|
2023-03-14 13:35:46 -04:00
|
|
|
{
|
2023-03-15 11:59:44 -04:00
|
|
|
void OutputInstanceLifetimeEvent(const FStateTreeInstanceDebugId InstanceId, const UStateTree* StateTree, const TCHAR* InstanceName, const EStateTreeTraceInstanceEventType EventType);
|
2023-04-19 13:26:23 -04:00
|
|
|
void OutputLogEventTrace(const FStateTreeInstanceDebugId InstanceId, const EStateTreeUpdatePhase Phase, const TCHAR* Fmt, ...);
|
|
|
|
|
void OutputStateEventTrace(const FStateTreeInstanceDebugId InstanceId, const EStateTreeUpdatePhase Phase, const uint16 StateIdx, const EStateTreeTraceNodeEventType EventType);
|
|
|
|
|
void OutputTaskEventTrace(const FStateTreeInstanceDebugId InstanceId, const EStateTreeUpdatePhase Phase, const uint16 TaskIdx, FStateTreeDataView DataView, const EStateTreeTraceNodeEventType EventType, const EStateTreeRunStatus Status);
|
|
|
|
|
void OutputConditionEventTrace(const FStateTreeInstanceDebugId InstanceId, const EStateTreeUpdatePhase Phase, const uint16 ConditionIdx, FStateTreeDataView DataView, const EStateTreeTraceNodeEventType EventType);
|
2023-03-15 11:59:44 -04:00
|
|
|
void OutputActiveStatesEventTrace(const FStateTreeInstanceDebugId InstanceId, const FStateTreeActiveStates& ActiveStates);
|
2023-04-19 13:26:23 -04:00
|
|
|
}
|
2023-03-14 13:35:46 -04:00
|
|
|
|
|
|
|
|
#define TRACE_STATETREE_INSTANCE_EVENT(InstanceID, StateTree, InstanceName, EventType) \
|
|
|
|
|
if (UE_TRACE_CHANNELEXPR_IS_ENABLED(StateTreeDebugChannel)) \
|
|
|
|
|
{ \
|
2023-03-15 11:59:44 -04:00
|
|
|
UE::StateTreeTrace::OutputInstanceLifetimeEvent(InstanceID, StateTree, InstanceName, EventType); \
|
2023-03-14 13:35:46 -04:00
|
|
|
}
|
|
|
|
|
|
2023-04-19 13:26:23 -04:00
|
|
|
#define TRACE_STATETREE_LOG_EVENT(InstanceId, Phase, Format, ...) \
|
2023-03-14 13:35:46 -04:00
|
|
|
if (UE_TRACE_CHANNELEXPR_IS_ENABLED(StateTreeDebugChannel)) \
|
|
|
|
|
{ \
|
2023-04-19 13:26:23 -04:00
|
|
|
UE::StateTreeTrace::OutputLogEventTrace(InstanceId, Phase, Format, ##__VA_ARGS__); \
|
2023-03-14 13:35:46 -04:00
|
|
|
}
|
|
|
|
|
|
2023-04-19 13:26:23 -04:00
|
|
|
#define TRACE_STATETREE_STATE_EVENT(InstanceId, Phase, StateIdx, EventType) \
|
2023-03-14 13:35:46 -04:00
|
|
|
if (UE_TRACE_CHANNELEXPR_IS_ENABLED(StateTreeDebugChannel)) \
|
|
|
|
|
{ \
|
2023-04-19 13:26:23 -04:00
|
|
|
UE::StateTreeTrace::OutputStateEventTrace(InstanceId, Phase, StateIdx, EventType); \
|
2023-03-14 13:35:46 -04:00
|
|
|
}
|
|
|
|
|
|
2023-04-19 13:26:23 -04:00
|
|
|
#define TRACE_STATETREE_TASK_EVENT(InstanceId, Phase, TaskIdx, DataView, EventType, Status) \
|
2023-03-14 13:35:46 -04:00
|
|
|
if (UE_TRACE_CHANNELEXPR_IS_ENABLED(StateTreeDebugChannel)) \
|
|
|
|
|
{ \
|
2023-04-19 13:26:23 -04:00
|
|
|
UE::StateTreeTrace::OutputTaskEventTrace(InstanceId, Phase, TaskIdx, DataView, EventType, Status); \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define TRACE_STATETREE_CONDITION_EVENT(InstanceId, Phase, ConditionIdx, DataView, EventType) \
|
|
|
|
|
if (UE_TRACE_CHANNELEXPR_IS_ENABLED(StateTreeDebugChannel)) \
|
|
|
|
|
{ \
|
|
|
|
|
UE::StateTreeTrace::OutputConditionEventTrace(InstanceId, Phase, ConditionIdx, DataView, EventType); \
|
2023-03-14 13:35:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define TRACE_STATETREE_ACTIVE_STATES_EVENT(InstanceId, ActivateStates) \
|
|
|
|
|
if (UE_TRACE_CHANNELEXPR_IS_ENABLED(StateTreeDebugChannel)) \
|
|
|
|
|
{ \
|
2023-03-15 11:59:44 -04:00
|
|
|
UE::StateTreeTrace::OutputActiveStatesEventTrace(InstanceId, ActivateStates); \
|
2023-03-14 13:35:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else //STATETREE_DEBUG_TRACE_ENABLED
|
|
|
|
|
|
|
|
|
|
#define TRACE_STATETREE_INSTANCE_EVENT(InstanceID, StateTree, InstanceName, EventType)
|
2023-04-19 13:26:23 -04:00
|
|
|
#define TRACE_STATETREE_LOG_EVENT(InstanceId, Phase, Format, ...)
|
|
|
|
|
#define TRACE_STATETREE_STATE_EVENT(InstanceId, Phase, StateIdx, EventType)
|
|
|
|
|
#define TRACE_STATETREE_TASK_EVENT(InstanceId, Phase, TaskIdx, DataView, EventType, Status)
|
|
|
|
|
#define TRACE_STATETREE_CONDITION_EVENT(InstanceId, Phase, ConditionIdx, DataView, EventType)
|
2023-03-14 13:35:46 -04:00
|
|
|
#define TRACE_STATETREE_ACTIVE_STATES_EVENT(InstanceId, ActivateStates)
|
|
|
|
|
|
|
|
|
|
#endif // STATETREE_DEBUG_TRACE_ENABLED
|