Various null checks, const correctness, remove unused headers

This commit is contained in:
Arnaud Jamin
2023-12-17 01:02:05 -05:00
parent a90881555b
commit 85a903a341
61 changed files with 346 additions and 369 deletions
@@ -127,7 +127,7 @@ void FCogAIWindow_BehaviorTree::RenderContent()
if (Config == nullptr)
{
ImGui::TextDisabled("No Config");
ImGui::TextDisabled("Invalid Config");
return;
}
@@ -148,35 +148,35 @@ void FCogAIWindow_BehaviorTree::RenderContent()
AActor* Selection = GetSelection();
if (Selection == nullptr)
{
ImGui::TextDisabled("No Selection");
ImGui::TextDisabled("Invalid Selection");
return;
}
APawn* Pawn = Cast<APawn>(Selection);
if (Pawn == nullptr)
{
ImGui::TextDisabled("Not a pawn");
ImGui::TextDisabled("Selection is not a pawn");
return;
}
AAIController* AIController = Cast<AAIController>(Pawn->Controller);
if (AIController == nullptr)
{
ImGui::TextDisabled("No AIController");
ImGui::TextDisabled("Selection has no AIController");
return;
}
UBehaviorTreeComponent* BehaviorTreeComponent = Cast<UBehaviorTreeComponent>(AIController->GetBrainComponent());
if (BehaviorTreeComponent == nullptr)
{
ImGui::TextDisabled("No BrainComponent");
ImGui::TextDisabled("Selection has no BrainComponent");
return;
}
UBehaviorTree* CurrentTree = BehaviorTreeComponent->GetCurrentTree();
if (CurrentTree == nullptr)
{
ImGui::TextDisabled("No Current Tree");
ImGui::TextDisabled("Selection has no current BehaviorTree");
return;
}
@@ -54,42 +54,42 @@ void FCogAIWindow_Blackboard::RenderContent()
AActor* Selection = GetSelection();
if (Selection == nullptr)
{
ImGui::TextDisabled("No Selection");
ImGui::TextDisabled("Invalid Selection");
return;
}
APawn* Pawn = Cast<APawn>(Selection);
if (Pawn == nullptr)
{
ImGui::TextDisabled("Not a pawn");
ImGui::TextDisabled("Selection is not a pawn");
return;
}
AAIController* AIController = Cast<AAIController>(Pawn->Controller);
if (AIController == nullptr)
{
ImGui::TextDisabled("No AIController");
ImGui::TextDisabled("Selection has no AIController");
return;
}
UBrainComponent* BehaviorTree = AIController->GetBrainComponent();
if (BehaviorTree == nullptr)
{
ImGui::TextDisabled("No BrainComponent");
ImGui::TextDisabled("Selection has no BrainComponent");
return;
}
UBlackboardComponent* Blackboard = BehaviorTree->GetBlackboardComponent();
if (Blackboard == nullptr)
{
ImGui::TextDisabled("No BlackboardComponent");
ImGui::TextDisabled("Selection has no BlackboardComponent");
return;
}
UBlackboardData* BlackboardAsset = Blackboard->GetBlackboardAsset();
if (BlackboardAsset == nullptr)
{
ImGui::TextDisabled("No BlackboardAsset");
ImGui::TextDisabled("Selection has no BlackboardAsset");
return;
}