diff --git a/Plugins/UEWingman/Source/UEWingman/Handlers/Blueprint_Dump.h b/Plugins/UEWingman/Source/UEWingman/Handlers/Blueprint_Dump.h index eb36843c..09f23ab8 100644 --- a/Plugins/UEWingman/Source/UEWingman/Handlers/Blueprint_Dump.h +++ b/Plugins/UEWingman/Source/UEWingman/Handlers/Blueprint_Dump.h @@ -71,22 +71,9 @@ public: BlueprintVars.Print(WingOut::StdoutBuffer); // Components - TArray Components3 = UWingComponentReference::GetAll(BP); - if (!Components3.IsEmpty()) - { - WingOut::Stdout.Print(TEXT("\nComponents:\n")); - for (const UWingComponentReference* Ref : Components3) - { - WingOut::Stdout.Printf(TEXT(" %s %s"), - *Ref->TypeName, - *WingUtils::FormatName(Ref)); - if (!Ref->ParentName.IsEmpty()) - WingOut::Stdout.Printf(TEXT(" [parent: %s]"), *Ref->ParentName); - if (Ref->Inherited) - WingOut::Stdout.Print(TEXT(" [inherited]")); - WingOut::Stdout.Print(TEXT("\n")); - } - } + TArray Components = UWingComponentReference::GetAll(BP); + if (!Components.IsEmpty()) WingOut::Stdout.Print(TEXT("\nComponents:\n")); + UWingComponentReference::PrintAll(BP, WingOut::Stdout); // Widget Tree if (UWidgetBlueprint* WidgetBP = Cast(BP)) diff --git a/Plugins/UEWingman/Source/UEWingman/Private/WingActorComponent.cpp b/Plugins/UEWingman/Source/UEWingman/Private/WingActorComponent.cpp index ac55e0a3..1e7aaff7 100644 --- a/Plugins/UEWingman/Source/UEWingman/Private/WingActorComponent.cpp +++ b/Plugins/UEWingman/Source/UEWingman/Private/WingActorComponent.cpp @@ -267,13 +267,59 @@ TArray UWingComponentReference::GetAll(UBlueprint* BP) UWingComponentReference* Ref = NewObject(); Ref->BP = BP; Ref->VariableName = Comp->GetFName(); - Ref->TypeName = UWingTypes::TypeToText(Comp->GetClass()); + Result.Add(Ref); + } + } + } + + // Visit all SCS nodes, oldest first. + for (UBlueprint *WalkBP : WingUtils::GetAncestorBlueprints(BP, true)) + { + if (WalkBP->SimpleConstructionScript == nullptr) continue; + for (USCS_Node* Node : WalkBP->SimpleConstructionScript->GetAllNodes()) + { + UWingComponentReference* Ref = NewObject(); + Ref->BP = BP; + Ref->VariableName = Node->GetVariableName(); + Result.Add(Ref); + } + } + + return Result; +} + +void UWingComponentReference::PrintComponentInfo(const FString& TypeName, const FString& VarName, const FString& ParentName, bool Inherited, WingOut Out) +{ + Out.Printf(TEXT(" %s %s"), *TypeName, *VarName); + if (!ParentName.IsEmpty()) + Out.Printf(TEXT(" [parent: %s]"), *ParentName); + if (Inherited) + Out.Print(TEXT(" [inherited]")); + Out.Print(TEXT("\n")); +} + +void UWingComponentReference::PrintAll(UBlueprint* BP, WingOut Out) +{ + if (!BP) return; + + // Find the native ancestor class + UClass* NativeClass = FBlueprintEditorUtils::FindFirstNativeClass(BP->ParentClass); + + // Native components from the native ancestor's CDO + if (NativeClass) + { + if (AActor* CDO = Cast(NativeClass->GetDefaultObject())) + { + TArray NativeComponents; + CDO->GetComponents(NativeComponents); + for (UActorComponent* Comp : NativeComponents) + { + FString ParentName; if (USceneComponent* Scene = Cast(Comp)) if (USceneComponent* AttachParent = Scene->GetAttachParent()) - Ref->ParentName = WingUtils::ExternalizeID(AttachParent->GetFName()); - Ref->Native = true; - Ref->Inherited = true; - Result.Add(Ref); + ParentName = WingUtils::ExternalizeID(AttachParent->GetFName()); + PrintComponentInfo(UWingTypes::TypeToText(Comp->GetClass()), + WingUtils::FormatName(Comp), ParentName, true, Out); } } } @@ -285,17 +331,10 @@ TArray UWingComponentReference::GetAll(UBlueprint* BP) TMap ParentNames = CalculateParentNames(WalkBP->SimpleConstructionScript); for (USCS_Node* Node : WalkBP->SimpleConstructionScript->GetAllNodes()) { - UWingComponentReference* Ref = NewObject(); - Ref->BP = BP; - Ref->VariableName = Node->GetVariableName(); - Ref->TypeName = UWingTypes::TypeToText(Node->ComponentClass); - Ref->ParentName = WingUtils::ExternalizeID(ParentNames[Node->GetVariableName()]); - Ref->Native = false; - Ref->Inherited = (WalkBP != BP); - Result.Add(Ref); + FString ParentName = WingUtils::ExternalizeID(ParentNames[Node->GetVariableName()]); + PrintComponentInfo(UWingTypes::TypeToText(Node->ComponentClass), + WingUtils::ExternalizeID(Node->GetVariableName()), + ParentName, WalkBP != BP, Out); } } - - return Result; } - diff --git a/Plugins/UEWingman/Source/UEWingman/Public/WingActorComponent.h b/Plugins/UEWingman/Source/UEWingman/Public/WingActorComponent.h index 29a610df..c4976f7f 100644 --- a/Plugins/UEWingman/Source/UEWingman/Public/WingActorComponent.h +++ b/Plugins/UEWingman/Source/UEWingman/Public/WingActorComponent.h @@ -27,26 +27,18 @@ public: // The component name. FName VariableName; - // Externalized Parent Name (for display only) - FString ParentName; - - // Externalized TypeName of the component (for display only) - FString TypeName; - - // True if the component is native (for display only) - bool Native = false; - - // True if the component was inherited (for display only) - bool Inherited = false; - UActorComponent* GetImmutableTemplate() const; UActorComponent* GetMutableTemplate() const; bool ReparentComponent(UWingComponentReference *Parent, WingOut Errors); bool DeleteComponent(WingOut Errors); - static bool AddComponent(UBlueprint *BP, UClass *Class, UWingComponentReference *Parent, FName Name, WingOut Errors); + static bool AddComponent(UBlueprint *BP, UClass *Class, + UWingComponentReference *Parent, FName Name, WingOut Errors); static TArray GetAll(UBlueprint* BP); + static void PrintAll(UBlueprint* BP, WingOut Out); + static void PrintComponentInfo(const FString& TypeName, const FString& VarName, + const FString& ParentName, bool Inherited, WingOut Out); static bool CheckValidComponentClass(UClass *Class, WingOut Errors); private: @@ -68,4 +60,3 @@ private: static void AddChildNode(UBlueprint *BP, USCS_Node *Node, FoundComponent Parent); static TMap CalculateParentNames(USimpleConstructionScript *Script); }; -