Agged GameplayTasks information to GameplayDebugger #UE4

[CL 2605455 by Mieszko Zielinski in Main branch]
This commit is contained in:
Mieszko Zielinski
2015-06-30 07:11:55 -04:00
committed by mieszko.zielinski@epicgames.com
parent ffdd157997
commit fb69a2c1c3
5 changed files with 58 additions and 29 deletions

View File

@@ -85,6 +85,9 @@ class GAMEPLAYDEBUGGER_API UGameplayDebuggingComponent : public UPrimitiveCompon
UPROPERTY(Replicated)
FString CurrentAIAssets;
UPROPERTY(Replicated)
FString GameplayTasksState;
UPROPERTY(Replicated)
FString NavDataInfo;

View File

@@ -214,6 +214,8 @@ void UGameplayDebuggingComponent::GetLifetimeReplicatedProps( TArray< FLifetimeP
DOREPLIFETIME(UGameplayDebuggingComponent, CurrentAIState);
DOREPLIFETIME(UGameplayDebuggingComponent, CurrentAIAssets);
DOREPLIFETIME(UGameplayDebuggingComponent, GameplayTasksState);
DOREPLIFETIME(UGameplayDebuggingComponent, bIsUsingAbilities);
DOREPLIFETIME(UGameplayDebuggingComponent, AbilityInfo);
@@ -531,6 +533,16 @@ void UGameplayDebuggingComponent::CollectBasicBehaviorData(APawn* MyPawn)
CurrentAIState = TEXT("");
CurrentAIAssets = TEXT("");
}
UGameplayTasksComponent* GTComponent = MyPawn->FindComponentByClass<UGameplayTasksComponent>();
if (GTComponent)
{
GameplayTasksState = FString::Printf(TEXT("Ticking Tasks: %s\nTask Queue: %s"), *GTComponent->GetTickingTasksDescription(), *GTComponent->GetTasksPriorityQueueDescription());
}
else
{
GameplayTasksState = TEXT("");
}
#endif //!(UE_BUILD_SHIPPING || UE_BUILD_TEST)
}

View File

@@ -395,7 +395,7 @@ void AGameplayDebuggingHUDComponent::DrawBasicData(APlayerController* PC, class
PrintString(DefaultContext, FString::Printf(TEXT("Behavior: {yellow}%s{white}, Tree: {yellow}%s\n"), *DebugComponent->CurrentAIState, *DebugComponent->CurrentAIAssets));
PrintString(DefaultContext, FString::Printf(TEXT("Active task: {yellow}%s\n"), *DebugComponent->CurrentAITask));
}
// ability + animation
if (DebugComponent->bIsUsingAbilities && DebugComponent->bIsUsingCharacter)
{
@@ -410,6 +410,9 @@ void AGameplayDebuggingHUDComponent::DrawBasicData(APlayerController* PC, class
PrintString(DefaultContext, FString::Printf(TEXT("Ability: {yellow}%s\n"), *DebugComponent->AbilityInfo));
}
// putting gameplay tasks' stuff last since it can expand heavily
PrintString(DefaultContext, FString::Printf(TEXT("GameplayTasks:\n{yellow}%s\n"), *DebugComponent->GameplayTasksState));
DrawPath(PC, DebugComponent);
#endif //!(UE_BUILD_SHIPPING || UE_BUILD_TEST)
}

View File

@@ -116,7 +116,9 @@ public:
static EGameplayTaskRunResult K2_RunGameplayTask(TScriptInterface<IGameplayTaskOwnerInterface> TaskOwner, UGameplayTask* Task, uint8 Priority, TArray<TSubclassOf<UGameplayTaskResource> > AdditionalRequiredResources, TArray<TSubclassOf<UGameplayTaskResource> > AdditionalClaimedResources);
static EGameplayTaskRunResult RunGameplayTask(IGameplayTaskOwnerInterface& TaskOwner, UGameplayTask& Task, uint8 Priority, FGameplayResourceSet AdditionalRequiredResources, FGameplayResourceSet AdditionalClaimedResources);
FString GetTickingTasksDescription() const;
FString GetTasksPriorityQueueDescription() const;
#if ENABLE_VISUAL_LOG
static FString GetTaskStateName(EGameplayTaskState Value);
void DescribeSelfToVisLog(struct FVisualLogEntry* Snapshot) const;

View File

@@ -428,6 +428,40 @@ void UGameplayTasksComponent::SetCurrentlyClaimedResources(FGameplayResourceSet
//----------------------------------------------------------------------//
// debugging
//----------------------------------------------------------------------//
FString UGameplayTasksComponent::GetTickingTasksDescription() const
{
FString TasksDescription;
for (auto& Task : TickingTasks)
{
if (Task.IsValid())
{
TasksDescription += FString::Printf(TEXT("\n%s %s"), *GetTaskStateName(Task->GetState()), *Task->GetDebugDescription());
}
else
{
TasksDescription += TEXT("\nNULL");
}
}
return TasksDescription;
}
FString UGameplayTasksComponent::GetTasksPriorityQueueDescription() const
{
FString TasksDescription;
for (auto Task : TaskPriorityQueue)
{
if (Task != nullptr)
{
TasksDescription += FString::Printf(TEXT("\n%s %s"), *GetTaskStateName(Task->GetState()), *Task->GetDebugDescription());
}
else
{
TasksDescription += TEXT("\nNULL");
}
}
return TasksDescription;
}
#if ENABLE_VISUAL_LOG
void UGameplayTasksComponent::DescribeSelfToVisLog(FVisualLogEntry* Snapshot) const
{
@@ -442,33 +476,8 @@ void UGameplayTasksComponent::DescribeSelfToVisLog(FVisualLogEntry* Snapshot) co
FVisualLogStatusCategory StatusCategory(CategoryName);
FString TasksDescription;
for (auto& Task : TickingTasks)
{
if (Task.IsValid())
{
TasksDescription += FString::Printf(TEXT("%s %s\n"), *GetTaskStateName(Task->GetState()), *Task->GetDebugDescription());
}
else
{
TasksDescription += TEXT("NULL\n");
}
}
StatusCategory.Add(TickingTasksName, TasksDescription);
TasksDescription.Reset();
for (auto Task : TaskPriorityQueue)
{
if (Task != nullptr)
{
TasksDescription += FString::Printf(TEXT("%s %s\n"), *GetTaskStateName(Task->GetState()), *Task->GetDebugDescription());
}
else
{
TasksDescription += TEXT("NULL\n");
}
}
StatusCategory.Add(PriorityQueueName, TasksDescription);
StatusCategory.Add(TickingTasksName, GetTickingTasksDescription());
StatusCategory.Add(PriorityQueueName, GetTasksPriorityQueueDescription());
Snapshot->Status.Add(StatusCategory);
}