Get rid of lxTangibleInterface

This commit is contained in:
2024-09-24 22:56:49 -04:00
parent a295ff5e53
commit 1f1f383da0
7 changed files with 36 additions and 41 deletions

Binary file not shown.

View File

@@ -114,7 +114,11 @@ void UlxTangible::MaybeExecuteAnimStateChanged() {
FString blueprint = AnimTracker.GetCurrentBlueprintName(); FString blueprint = AnimTracker.GetCurrentBlueprintName();
if (blueprint.IsEmpty()) blueprint = DEFAULT_BLUEPRINT; if (blueprint.IsEmpty()) blueprint = DEFAULT_BLUEPRINT;
SetActorBlueprint(blueprint); SetActorBlueprint(blueprint);
IlxTangibleInterface::Execute_AnimationQueueChanged(GetActor()); AActor *actor = GetActor();
UFunction *aqchanged = UlxTangibleManager::GetAnimationQueueChanged(actor->GetClass());
if (aqchanged != nullptr) {
actor->ProcessEvent(aqchanged, nullptr);
}
} }
} }

View File

@@ -10,34 +10,6 @@
class UlxTangibleManager; 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();
};
/** /**
* *

View File

@@ -10,6 +10,13 @@ using namespace DebugPrint;
using TanArray = UlxTangibleManager::TanArray; using TanArray = UlxTangibleManager::TanArray;
using IdArray = UlxTangibleManager::IdArray; 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) { UClass *UlxTangibleManager::GetTangibleClass(const FString &name) {
if (name.IsEmpty()) { if (name.IsEmpty()) {
return nullptr; return nullptr;
@@ -22,13 +29,18 @@ UClass *UlxTangibleManager::GetTangibleClass(const FString &name) {
path += TCHAR('_'); path += TCHAR('_');
path += TCHAR('C'); path += TCHAR('C');
UClass *result = LoadObject<UClass>(nullptr, *path); UClass *result = LoadObject<UClass>(nullptr, *path);
if (result != nullptr) { if (result == nullptr) {
if (!result->IsChildOf(AActor::StaticClass())) { UE_LOG(LogBlueprint, Error, TEXT("No such UClass: %s"), *path);
return nullptr; return nullptr;
} }
if (!result->ImplementsInterface(UlxTangibleInterface::StaticClass())) { if (!result->IsChildOf(AActor::StaticClass())) {
return nullptr; 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; return result;
} }

View File

@@ -101,5 +101,9 @@ public:
// Convert a blueprint name to a blueprint class. // Convert a blueprint name to a blueprint class.
// //
UClass *GetTangibleClass(const FString &name); UClass *GetTangibleClass(const FString &name);
// Get the Animation Queue Changed function from a UClass.
//
static UFunction *GetAnimationQueueChanged(UClass *uclass);
}; };

View File

@@ -22,7 +22,10 @@ void UlxUtilityLibrary::CallFunctionByName(UObject *object, const FString &namep
FBlueprintCoreDelegates::ThrowScriptException(FFrame::GetThreadLocalTopStackFrame()->Object, *FFrame::GetThreadLocalTopStackFrame(), ExceptionInfo); FBlueprintCoreDelegates::ThrowScriptException(FFrame::GetThreadLocalTopStackFrame()->Object, *FFrame::GetThreadLocalTopStackFrame(), ExceptionInfo);
return; 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) { if (function == nullptr) {
function = object->FindFunction(FName(*fallback)); function = object->FindFunction(FName(*fallback));
if (function == nullptr) { if (function == nullptr) {