From 1f1f383da0e6e72ecb2636ec19c7587bb32e6034 Mon Sep 17 00:00:00 2001 From: jyelon Date: Tue, 24 Sep 2024 22:56:49 -0400 Subject: [PATCH] Get rid of lxTangibleInterface --- Content/Tangibles/TangibleStaticMesh.uasset | 4 +-- Content/Tangibles/tangiblecharacter.uasset | 4 +-- Source/Integration/Tangible.cpp | 6 ++++- Source/Integration/Tangible.h | 28 --------------------- Source/Integration/TangibleManager.cpp | 26 +++++++++++++------ Source/Integration/TangibleManager.h | 4 +++ Source/Integration/UtilityLibrary.cpp | 5 +++- 7 files changed, 36 insertions(+), 41 deletions(-) diff --git a/Content/Tangibles/TangibleStaticMesh.uasset b/Content/Tangibles/TangibleStaticMesh.uasset index 15cee6af..62a5f0f2 100644 --- a/Content/Tangibles/TangibleStaticMesh.uasset +++ b/Content/Tangibles/TangibleStaticMesh.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:99fda10417bc30a55d5e74ceffa8da3d457636154e4dba697d64fe5c6de96cd9 -size 272097 +oid sha256:68e750faad98195083ce2162f12e1b34940b83bdf137227de5b48669cb41032b +size 266069 diff --git a/Content/Tangibles/tangiblecharacter.uasset b/Content/Tangibles/tangiblecharacter.uasset index 7a22844a..1cfdaee4 100644 --- a/Content/Tangibles/tangiblecharacter.uasset +++ b/Content/Tangibles/tangiblecharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a6086b0657e5c5de22e49eba805ea82d2f9170f68dd3ec8fe731effebb43426d -size 395326 +oid sha256:00f3431474dcca1b28ba7ce0f893ad7c8df012190eb49e12e1f0f65c03e8f7ee +size 394328 diff --git a/Source/Integration/Tangible.cpp b/Source/Integration/Tangible.cpp index 33499d64..2b73e44e 100644 --- a/Source/Integration/Tangible.cpp +++ b/Source/Integration/Tangible.cpp @@ -114,7 +114,11 @@ void UlxTangible::MaybeExecuteAnimStateChanged() { FString blueprint = AnimTracker.GetCurrentBlueprintName(); if (blueprint.IsEmpty()) blueprint = DEFAULT_BLUEPRINT; SetActorBlueprint(blueprint); - IlxTangibleInterface::Execute_AnimationQueueChanged(GetActor()); + AActor *actor = GetActor(); + UFunction *aqchanged = UlxTangibleManager::GetAnimationQueueChanged(actor->GetClass()); + if (aqchanged != nullptr) { + actor->ProcessEvent(aqchanged, nullptr); + } } } diff --git a/Source/Integration/Tangible.h b/Source/Integration/Tangible.h index a4e5c3b2..878bd529 100644 --- a/Source/Integration/Tangible.h +++ b/Source/Integration/Tangible.h @@ -10,34 +10,6 @@ class UlxTangibleManager; -// This class does not need to be modified. -UINTERFACE(Blueprintable) -class UlxTangibleInterface : public UInterface -{ - GENERATED_BODY() -}; - -/** - * - * IlxTangibleInterface - * - * This class implements the interface that an Actor must implement - * in order for that Actor to be usable as a Tangible. - * - */ - -class INTEGRATION_API IlxTangibleInterface -{ - GENERATED_BODY() - - // Add interface functions to this class. This is the class that will be inherited to implement this interface. -public: - // Whenever the animation queue of a tangible changes in any way, this function - // gets called automatically. - UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Animation Queue") - bool AnimationQueueChanged(); -}; - /** * diff --git a/Source/Integration/TangibleManager.cpp b/Source/Integration/TangibleManager.cpp index 45dac241..f79a3d3f 100644 --- a/Source/Integration/TangibleManager.cpp +++ b/Source/Integration/TangibleManager.cpp @@ -10,6 +10,13 @@ using namespace DebugPrint; using TanArray = UlxTangibleManager::TanArray; using IdArray = UlxTangibleManager::IdArray; +UFunction *UlxTangibleManager::GetAnimationQueueChanged(UClass *uclass) { + UFunction *result = uclass->FindFunctionByName(FName(TEXT("Animation Queue Changed"))); + if (result == nullptr) return nullptr; + if (result->ParmsSize != 0) return nullptr; + return result; +} + UClass *UlxTangibleManager::GetTangibleClass(const FString &name) { if (name.IsEmpty()) { return nullptr; @@ -22,13 +29,18 @@ UClass *UlxTangibleManager::GetTangibleClass(const FString &name) { path += TCHAR('_'); path += TCHAR('C'); UClass *result = LoadObject(nullptr, *path); - if (result != nullptr) { - if (!result->IsChildOf(AActor::StaticClass())) { - return nullptr; - } - if (!result->ImplementsInterface(UlxTangibleInterface::StaticClass())) { - return nullptr; - } + if (result == nullptr) { + UE_LOG(LogBlueprint, Error, TEXT("No such UClass: %s"), *path); + return nullptr; + } + if (!result->IsChildOf(AActor::StaticClass())) { + UE_LOG(LogBlueprint, Error, TEXT("UClass is not an actor: %s"), *path); + return nullptr; + } + UFunction *aqchanged = GetAnimationQueueChanged(result); + if (aqchanged == nullptr) { + UE_LOG(LogBlueprint, Error, TEXT("UClass does not have 'Animation Queue Changed' function: %s"), *path); + return nullptr; } return result; } diff --git a/Source/Integration/TangibleManager.h b/Source/Integration/TangibleManager.h index 8bcae11d..8f59d089 100644 --- a/Source/Integration/TangibleManager.h +++ b/Source/Integration/TangibleManager.h @@ -101,5 +101,9 @@ public: // Convert a blueprint name to a blueprint class. // UClass *GetTangibleClass(const FString &name); + + // Get the Animation Queue Changed function from a UClass. + // + static UFunction *GetAnimationQueueChanged(UClass *uclass); }; diff --git a/Source/Integration/UtilityLibrary.cpp b/Source/Integration/UtilityLibrary.cpp index 6a1b28ea..10710ae6 100644 --- a/Source/Integration/UtilityLibrary.cpp +++ b/Source/Integration/UtilityLibrary.cpp @@ -22,7 +22,10 @@ void UlxUtilityLibrary::CallFunctionByName(UObject *object, const FString &namep FBlueprintCoreDelegates::ThrowScriptException(FFrame::GetThreadLocalTopStackFrame()->Object, *FFrame::GetThreadLocalTopStackFrame(), ExceptionInfo); return; } - UFunction* function = object->FindFunction(FName(*fullname)); +// UFunction* function = object->FindFunction(FName(*fullname)); + + UClass *uclass = object->GetClass(); + UFunction* function = uclass->FindFunctionByName(FName(*fullname)); if (function == nullptr) { function = object->FindFunction(FName(*fallback)); if (function == nullptr) {