diff --git a/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Add.h b/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Add.h index 5fc9b61b..b661010b 100644 --- a/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Add.h +++ b/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Add.h @@ -6,7 +6,7 @@ #include "WingUtils.h" #include "WingTypes.h" #include "WingServer.h" -#include "WingActorComponent.h" +#include "WingComponent.h" #include "Engine/Blueprint.h" #include "Engine/SimpleConstructionScript.h" #include "Engine/SCS_Node.h" @@ -64,15 +64,15 @@ public: if (!UWingTypes::TextToType(Class, PinType, Req, WingOut::Stdout)) return; UClass* ComponentClass = Cast(PinType.PinSubCategoryObject.Get()); check(ComponentClass); - if (!UWingComponentReference::CheckValidComponentClass(ComponentClass, WingOut::Stdout)) return; + if (!UWingComponent::CheckValidComponentClass(ComponentClass, WingOut::Stdout)) return; // Find the specified parent component - TArray AllComponents = UWingComponentReference::GetAll(BP); + TArray AllComponents = UWingComponent::GetAll(BP); UWingComponentReference* ParentComp = WingUtils::FindOneWithExternalID(Parent, AllComponents, TEXT("Component"), WingOut::Stdout); if (!ParentComp) return; // Create the SCS node - if (!UWingComponentReference::AddComponent(BP, ComponentClass, ParentComp, InternalID, WingOut::Stdout)) return; + if (!UWingComponent::AddComponent(BP, ComponentClass, ParentComp, InternalID, WingOut::Stdout)) return; WingOut::Stdout.Printf(TEXT("Component Added.\n")); } diff --git a/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Remove.h b/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Remove.h index dfbfac8d..06f9b50a 100644 --- a/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Remove.h +++ b/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Remove.h @@ -4,7 +4,7 @@ #include "WingBasics.h" #include "WingFetcher.h" #include "WingServer.h" -#include "WingActorComponent.h" +#include "WingComponent.h" #include "ActorComponent_Remove.generated.h" @@ -32,7 +32,7 @@ public: UWingComponentReference* CompRef = F.Walk(Component).Cast(); if (!CompRef) return; - if (!CompRef->DeleteComponent(WingOut::Stdout)) return; + if (!UWingComponent::DeleteComponent(CompRef, WingOut::Stdout)) return; WingOut::Stdout.Printf(TEXT("Removed component.\n")); } diff --git a/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Reparent.h b/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Reparent.h index 4fa179a7..e9e8861b 100644 --- a/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Reparent.h +++ b/Plugins/UEWingman/Source/UEWingman/Handlers/ActorComponent_Reparent.h @@ -5,7 +5,7 @@ #include "WingFetcher.h" #include "WingUtils.h" #include "WingServer.h" -#include "WingActorComponent.h" +#include "WingComponent.h" #include "Engine/Blueprint.h" #include "Engine/SimpleConstructionScript.h" #include "Engine/SCS_Node.h" @@ -41,11 +41,11 @@ public: // Find the new parent among all components (if specified) UBlueprint *BP = CompRef->BP; - TArray AllComponents = UWingComponentReference::GetAll(BP); + TArray AllComponents = UWingComponent::GetAll(BP); UWingComponentReference* NewParent = WingUtils::FindOneWithExternalID(Parent, AllComponents, TEXT("Component"), WingOut::Stdout); if (!NewParent) return; - if (!CompRef->ReparentComponent(NewParent, WingOut::Stdout)) return; + if (!UWingComponent::ReparentComponent(CompRef, NewParent, WingOut::Stdout)) return; WingOut::Stdout.Printf(TEXT("Reparented component.")); } diff --git a/Plugins/UEWingman/Source/UEWingman/Handlers/Blueprint_Dump.h b/Plugins/UEWingman/Source/UEWingman/Handlers/Blueprint_Dump.h index 09f23ab8..3deccec9 100644 --- a/Plugins/UEWingman/Source/UEWingman/Handlers/Blueprint_Dump.h +++ b/Plugins/UEWingman/Source/UEWingman/Handlers/Blueprint_Dump.h @@ -9,7 +9,7 @@ #include "Engine/Blueprint.h" #include "Animation/AnimBlueprint.h" #include "Animation/Skeleton.h" -#include "WingActorComponent.h" +#include "WingComponent.h" #include "Kismet2/BlueprintEditorUtils.h" #include "AnimationGraph.h" #include "AnimationGraphSchema.h" @@ -71,9 +71,9 @@ public: BlueprintVars.Print(WingOut::StdoutBuffer); // Components - TArray Components = UWingComponentReference::GetAll(BP); + TArray Components = UWingComponent::GetAll(BP); if (!Components.IsEmpty()) WingOut::Stdout.Print(TEXT("\nComponents:\n")); - UWingComponentReference::PrintAll(BP, WingOut::Stdout); + UWingComponent::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/WingComponent.cpp similarity index 75% rename from Plugins/UEWingman/Source/UEWingman/Private/WingActorComponent.cpp rename to Plugins/UEWingman/Source/UEWingman/Private/WingComponent.cpp index 1e7aaff7..4f7267fd 100644 --- a/Plugins/UEWingman/Source/UEWingman/Private/WingActorComponent.cpp +++ b/Plugins/UEWingman/Source/UEWingman/Private/WingComponent.cpp @@ -1,4 +1,4 @@ -#include "WingActorComponent.h" +#include "WingComponent.h" #include "WingServer.h" #include "WingTypes.h" #include "WingUtils.h" @@ -11,7 +11,7 @@ #include "Kismet2/BlueprintEditorUtils.h" #include "Engine/InheritableComponentHandler.h" -UActorComponent *UWingComponentReference::FindComponentInCDO(UClass *Class, FName Name) +UActorComponent *UWingComponent::FindComponentInCDO(UClass *Class, FName Name) { if (!Class) return nullptr; AActor* CDO = Cast(Class->GetDefaultObject()); @@ -19,7 +19,7 @@ UActorComponent *UWingComponentReference::FindComponentInCDO(UClass *Class, FNam return FindObjectFast(CDO, Name); } -USCS_Node* UWingComponentReference::FindSCSNodeByName(UBlueprint *BP, FName Name) +USCS_Node* UWingComponent::FindSCSNodeByName(UBlueprint *BP, FName Name) { for (UBlueprint *WalkBP : WingUtils::GetAncestorBlueprints(BP)) { @@ -30,7 +30,7 @@ USCS_Node* UWingComponentReference::FindSCSNodeByName(UBlueprint *BP, FName Name return nullptr; } -UWingComponentReference::FoundComponent UWingComponentReference::FindComponent(UBlueprint *BP, FName Name) +UWingComponent::FoundComponent UWingComponent::FindComponent(UBlueprint *BP, FName Name) { UClass* NativeClass = FBlueprintEditorUtils::FindFirstNativeClass(BP->ParentClass); FoundComponent Result; @@ -40,7 +40,7 @@ UWingComponentReference::FoundComponent UWingComponentReference::FindComponent(U return Result; } -bool UWingComponentReference::CheckExists(UWingComponentReference::FoundComponent FC, WingOut Errors) +bool UWingComponent::CheckExists(UWingComponent::FoundComponent FC, WingOut Errors) { if ((FC.SCS == nullptr) && (FC.Native == nullptr)) { @@ -50,7 +50,7 @@ bool UWingComponentReference::CheckExists(UWingComponentReference::FoundComponen return true; } -bool UWingComponentReference::CheckValidParent(UWingComponentReference::FoundComponent FC, WingOut Errors) +bool UWingComponent::CheckValidParent(UWingComponent::FoundComponent FC, WingOut Errors) { if (FC.SCS && FC.Native) { @@ -73,7 +73,7 @@ bool UWingComponentReference::CheckValidParent(UWingComponentReference::FoundCom return true; } -bool UWingComponentReference::CheckNoSuchComponent(FoundComponent FC, WingOut Errors) +bool UWingComponent::CheckNoSuchComponent(FoundComponent FC, WingOut Errors) { if (FC.SCS || FC.Native) { @@ -84,7 +84,7 @@ bool UWingComponentReference::CheckNoSuchComponent(FoundComponent FC, WingOut Er return true; } -bool UWingComponentReference::CheckNotNative(FoundComponent FC, const TCHAR *Action, WingOut Errors) +bool UWingComponent::CheckNotNative(FoundComponent FC, const TCHAR *Action, WingOut Errors) { if (FC.Native != nullptr) { @@ -95,7 +95,7 @@ bool UWingComponentReference::CheckNotNative(FoundComponent FC, const TCHAR *Act return true; } -bool UWingComponentReference::CheckOwnedByBlueprint(FoundComponent FC, UBlueprint *BP, WingOut Errors) +bool UWingComponent::CheckOwnedByBlueprint(FoundComponent FC, UBlueprint *BP, WingOut Errors) { if ((FC.SCS == nullptr) || (FC.SCS->GetSCS() != BP->SimpleConstructionScript)) { @@ -106,7 +106,7 @@ bool UWingComponentReference::CheckOwnedByBlueprint(FoundComponent FC, UBlueprin return true; } -bool UWingComponentReference::CheckValidComponentClass(UClass *Class, WingOut Errors) +bool UWingComponent::CheckValidComponentClass(UClass *Class, WingOut Errors) { if (!Class->IsChildOf(UActorComponent::StaticClass())) { @@ -118,7 +118,7 @@ bool UWingComponentReference::CheckValidComponentClass(UClass *Class, WingOut Er } -void UWingComponentReference::AddChildNode(UBlueprint *BP, USCS_Node *NewNode, FoundComponent Parent) +void UWingComponent::AddChildNode(UBlueprint *BP, USCS_Node *NewNode, FoundComponent Parent) { if (Parent.SCS) { @@ -139,7 +139,7 @@ void UWingComponentReference::AddChildNode(UBlueprint *BP, USCS_Node *NewNode, F } } -bool UWingComponentReference::AddComponent(UBlueprint *BP, UClass *Class, UWingComponentReference *Parent, FName Name, WingOut Errors) +bool UWingComponent::AddComponent(UBlueprint *BP, UClass *Class, UWingComponentReference *Parent, FName Name, WingOut Errors) { TSet Names; FBlueprintEditorUtils::GetClassVariableList(BP, Names); @@ -167,14 +167,14 @@ bool UWingComponentReference::AddComponent(UBlueprint *BP, UClass *Class, UWingC return true; } -bool UWingComponentReference::ReparentComponent(UWingComponentReference *Parent, WingOut Errors) +bool UWingComponent::ReparentComponent(UWingComponentReference *Ref, UWingComponentReference *Parent, WingOut Errors) { - FoundComponent ParentComponent = FindComponent(BP, Parent->VariableName); + FoundComponent ParentComponent = FindComponent(Ref->BP, Parent->VariableName); if (!CheckValidParent(ParentComponent, Errors)) return false; - FoundComponent ThisComponent = FindComponent(BP, VariableName); + FoundComponent ThisComponent = FindComponent(Ref->BP, Ref->VariableName); if (!CheckExists(ThisComponent, Errors)) return false; if (!CheckNotNative(ThisComponent, TEXT("reparent"), Errors)) return false; - if (!CheckOwnedByBlueprint(ThisComponent, BP, Errors)) return false; + if (!CheckOwnedByBlueprint(ThisComponent, Ref->BP, Errors)) return false; if (ParentComponent.SCS && ParentComponent.SCS->IsChildOf(ThisComponent.SCS)) { @@ -182,22 +182,22 @@ bool UWingComponentReference::ReparentComponent(UWingComponentReference *Parent, return false; } - BP->SimpleConstructionScript->RemoveNode(ThisComponent.SCS); - AddChildNode(BP, ThisComponent.SCS, ParentComponent); + Ref->BP->SimpleConstructionScript->RemoveNode(ThisComponent.SCS); + AddChildNode(Ref->BP, ThisComponent.SCS, ParentComponent); return true; } -bool UWingComponentReference::DeleteComponent(WingOut Errors) +bool UWingComponent::DeleteComponent(UWingComponentReference *Ref, WingOut Errors) { - FoundComponent ThisComponent = FindComponent(BP, VariableName); + FoundComponent ThisComponent = FindComponent(Ref->BP, Ref->VariableName); if (!CheckExists(ThisComponent, Errors)) return false; if (!CheckNotNative(ThisComponent, TEXT("delete"), Errors)) return false; - if (!CheckOwnedByBlueprint(ThisComponent, BP, Errors)) return false; - BP->SimpleConstructionScript->RemoveNodeAndPromoteChildren(ThisComponent.SCS); + if (!CheckOwnedByBlueprint(ThisComponent, Ref->BP, Errors)) return false; + Ref->BP->SimpleConstructionScript->RemoveNodeAndPromoteChildren(ThisComponent.SCS); return true; } -TMap UWingComponentReference::CalculateParentNames(USimpleConstructionScript *Script) +TMap UWingComponent::CalculateParentNames(USimpleConstructionScript *Script) { TMap ParentNames; for (USCS_Node* Node : Script->GetAllNodes()) @@ -214,14 +214,14 @@ TMap UWingComponentReference::CalculateParentNames(USimpleConstruc return ParentNames; } -UActorComponent* UWingComponentReference::GetImmutableTemplate() const +UActorComponent* UWingComponent::GetImmutableTemplate(const UWingComponentReference *Ref) { - FoundComponent FC = FindComponent(BP, VariableName); + FoundComponent FC = FindComponent(Ref->BP, Ref->VariableName); if (FC.Native) return FC.Native; if (FC.SCS == nullptr) return nullptr; FComponentKey Key(FC.SCS); - for (UBlueprint *WalkBP : WingUtils::GetAncestorBlueprints(BP, false)) + for (UBlueprint *WalkBP : WingUtils::GetAncestorBlueprints(Ref->BP, false)) { if (FC.SCS->GetSCS()->GetBlueprint() == WalkBP) return FC.SCS->ComponentTemplate; UInheritableComponentHandler* ICH = WalkBP->GetInheritableComponentHandler(/*bCreateIfNecessary=*/ false); @@ -232,22 +232,22 @@ UActorComponent* UWingComponentReference::GetImmutableTemplate() const return nullptr; } -UActorComponent* UWingComponentReference::GetMutableTemplate() const +UActorComponent* UWingComponent::GetMutableTemplate(const UWingComponentReference *Ref) { - FoundComponent FC = FindComponent(BP, VariableName); + FoundComponent FC = FindComponent(Ref->BP, Ref->VariableName); if (FC.Native) return FC.Native; if (!FC.SCS) return nullptr; - if (FC.SCS->GetSCS()->GetBlueprint() == BP) return FC.SCS->ComponentTemplate; + if (FC.SCS->GetSCS()->GetBlueprint() == Ref->BP) return FC.SCS->ComponentTemplate; FComponentKey Key(FC.SCS); - UInheritableComponentHandler* ICH = BP->GetInheritableComponentHandler(/*bCreateIfNecessary=*/ true); + UInheritableComponentHandler* ICH = Ref->BP->GetInheritableComponentHandler(/*bCreateIfNecessary=*/ true); if (!ICH) return nullptr; UActorComponent* Override = ICH->GetOverridenComponentTemplate(Key); if (!Override) Override = ICH->CreateOverridenComponentTemplate(Key); return Override; } -TArray UWingComponentReference::GetAll(UBlueprint* BP) +TArray UWingComponent::GetAll(UBlueprint* BP) { TArray Result; if (!BP) return Result; @@ -288,7 +288,7 @@ TArray UWingComponentReference::GetAll(UBlueprint* BP) return Result; } -void UWingComponentReference::PrintComponentInfo(const FString& TypeName, const FString& VarName, const FString& ParentName, bool Inherited, WingOut Out) +void UWingComponent::PrintComponentInfo(const FString& TypeName, const FString& VarName, const FString& ParentName, bool Inherited, WingOut Out) { Out.Printf(TEXT(" %s %s"), *TypeName, *VarName); if (!ParentName.IsEmpty()) @@ -298,7 +298,7 @@ void UWingComponentReference::PrintComponentInfo(const FString& TypeName, const Out.Print(TEXT("\n")); } -void UWingComponentReference::PrintAll(UBlueprint* BP, WingOut Out) +void UWingComponent::PrintAll(UBlueprint* BP, WingOut Out) { if (!BP) return; diff --git a/Plugins/UEWingman/Source/UEWingman/Private/WingFetcher.cpp b/Plugins/UEWingman/Source/UEWingman/Private/WingFetcher.cpp index ef07a273..67a95930 100644 --- a/Plugins/UEWingman/Source/UEWingman/Private/WingFetcher.cpp +++ b/Plugins/UEWingman/Source/UEWingman/Private/WingFetcher.cpp @@ -2,7 +2,7 @@ #include "WingServer.h" #include "WingBasics.h" #include "WingUtils.h" -#include "WingActorComponent.h" +#include "WingComponent.h" #include "WingReferences.h" #include "Engine/Blueprint.h" #include "EdGraph/EdGraph.h" @@ -286,7 +286,7 @@ WingFetcher& WingFetcher::Component(const FString& Value) return SetError(); } - TArray AllComponents = UWingComponentReference::GetAll(BP); + TArray AllComponents = UWingComponent::GetAll(BP); UWingComponentReference* Found = WingUtils::FindOneWithExternalID(Value, AllComponents, TEXT("component"), Errors); if (!Found) { diff --git a/Plugins/UEWingman/Source/UEWingman/Private/WingProperty.cpp b/Plugins/UEWingman/Source/UEWingman/Private/WingProperty.cpp index 5ac72908..871428af 100644 --- a/Plugins/UEWingman/Source/UEWingman/Private/WingProperty.cpp +++ b/Plugins/UEWingman/Source/UEWingman/Private/WingProperty.cpp @@ -1,5 +1,5 @@ #include "WingProperty.h" -#include "WingActorComponent.h" +#include "WingComponent.h" #include "WingUtils.h" #include "WingBasics.h" #include "WingReferences.h" @@ -455,7 +455,7 @@ TArray FWingProperty::GetDetails(UObject* Obj, bool Mutable) // Component references: get the proper template. if (UWingComponentReference* Ref = ::Cast(Obj)) { - Obj = Mutable ? Ref->GetMutableTemplate() : Ref->GetImmutableTemplate(); + Obj = Mutable ? UWingComponent::GetMutableTemplate(Ref) : UWingComponent::GetImmutableTemplate(Ref); if (!Obj) { WingOut::Stdout.Printf(TEXT("ERROR: Component '%s' has no template\n"), *Ref->VariableName.ToString()); diff --git a/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp b/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp index f6d4a63d..d26ae413 100644 --- a/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp +++ b/Plugins/UEWingman/Source/UEWingman/Private/WingUtils.cpp @@ -1,5 +1,5 @@ #include "WingUtils.h" -#include "WingActorComponent.h" +#include "WingComponent.h" #include "WingProperty.h" #include "WingTypes.h" #include "WingServer.h" diff --git a/Plugins/UEWingman/Source/UEWingman/Public/WingActorComponent.h b/Plugins/UEWingman/Source/UEWingman/Public/WingComponent.h similarity index 81% rename from Plugins/UEWingman/Source/UEWingman/Public/WingActorComponent.h rename to Plugins/UEWingman/Source/UEWingman/Public/WingComponent.h index 93609af1..300fc892 100644 --- a/Plugins/UEWingman/Source/UEWingman/Public/WingActorComponent.h +++ b/Plugins/UEWingman/Source/UEWingman/Public/WingComponent.h @@ -2,7 +2,7 @@ #include "CoreMinimal.h" #include "WingBasics.h" -#include "WingActorComponent.generated.h" +#include "WingComponent.generated.h" class UBlueprint; class USCS_Node; @@ -24,12 +24,16 @@ public: // The component name. FName VariableName; +}; - UActorComponent* GetImmutableTemplate() const; - UActorComponent* GetMutableTemplate() const; +struct UWingComponent +{ +public: + static UActorComponent* GetImmutableTemplate(const UWingComponentReference *Ref); + static UActorComponent* GetMutableTemplate(const UWingComponentReference *Ref); - bool ReparentComponent(UWingComponentReference *Parent, WingOut Errors); - bool DeleteComponent(WingOut Errors); + static bool ReparentComponent(UWingComponentReference *Ref, UWingComponentReference *Parent, WingOut Errors); + static bool DeleteComponent(UWingComponentReference *Ref, WingOut Errors); static bool AddComponent(UBlueprint *BP, UClass *Class, UWingComponentReference *Parent, FName Name, WingOut Errors); diff --git a/Plugins/UEWingman/Source/UEWingman/Public/WingUtils.h b/Plugins/UEWingman/Source/UEWingman/Public/WingUtils.h index 50702182..6879225d 100644 --- a/Plugins/UEWingman/Source/UEWingman/Public/WingUtils.h +++ b/Plugins/UEWingman/Source/UEWingman/Public/WingUtils.h @@ -13,7 +13,7 @@ #include "Engine/Blueprint.h" #include "K2Node_EditablePinBase.h" #include "Components/Widget.h" -#include "WingActorComponent.h" +#include "WingComponent.h" #include "WingVariables.h" #include "WingBasics.h"