From 0b5fc799ac5531d7e83e96ba0cb435adf2641c77 Mon Sep 17 00:00:00 2001 From: jyelon Date: Wed, 20 Sep 2023 01:40:58 -0400 Subject: [PATCH] Some minor touchups to FlxAnimationStep --- Content/TangibleActor.uasset | 4 +-- Source/Integration/AnimQueue.cpp | 45 ++++++++++++++++++++++++++++++-- Source/Integration/AnimQueue.h | 19 +++++++++++--- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/Content/TangibleActor.uasset b/Content/TangibleActor.uasset index 42e011e4..d3ef1772 100644 --- a/Content/TangibleActor.uasset +++ b/Content/TangibleActor.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:595ddbe1ad470359c21f25fc41afb5692cae59238999273975cc805d83665524 -size 68824 +oid sha256:f55b8b1967273b907cccf5f44a780d091c4bacba418c4d371192c4d0709e07c5 +size 82316 diff --git a/Source/Integration/AnimQueue.cpp b/Source/Integration/AnimQueue.cpp index d6d6f0d4..28983a7a 100644 --- a/Source/Integration/AnimQueue.cpp +++ b/Source/Integration/AnimQueue.cpp @@ -86,10 +86,51 @@ FString UlxAnimationStepLibrary::AnimationStepDebugString(const FlxAnimationStep } void UlxAnimationStepLibrary::UnpackAnimationStep(const FlxAnimationStep& step, - const FString& prefix, UObject* into, bool preclear) { - step.Unpack(prefix, into, preclear); + const FString& prefix, UObject* into) { + step.Unpack(prefix, into, true); }; +static FlxAnimationField FindAnimationField(const FlxAnimationStep& step, const FString& name) { + std::string_view body((const char*)(step.Body.GetData()), step.Body.Num()); + FTCHARToUTF8 utf8name(name); + std::string_view uname(utf8name.Get(), utf8name.Length()); + FlxAnimationStepDecoder decoder(body); + FlxAnimationField result; + while (!decoder.AtEOF()) { + result = decoder.ReadField(); + if (result.Name == uname) { + return result; + } + } + result.Type = ElxAnimValueType::INVALID; + return result; +} + +FVector UlxAnimationStepLibrary::AnimationStepGetVector(const FlxAnimationStep& step, const FString& name) { + FlxAnimationField field = FindAnimationField(step, name); + if (field.Type != ElxAnimValueType::XYZ) return FVector(0, 0, 0); + return FVector(field.X, field.Y, field.Z); +} + +double UlxAnimationStepLibrary::AnimationStepGetFloat(const FlxAnimationStep& step, const FString& name) { + FlxAnimationField field = FindAnimationField(step, name); + if (field.Type != ElxAnimValueType::NUMBER) return 0.0; + return field.X; +} + +#pragma optimize("", off) +FString UlxAnimationStepLibrary::AnimationStepGetString(const FlxAnimationStep& step, const FString& name) { + FlxAnimationField field = FindAnimationField(step, name); + if (field.Type != ElxAnimValueType::STRING) return TEXT(""); + return FString(field.S.size(), (const UTF8CHAR*)(field.S.data())); +} + +bool UlxAnimationStepLibrary::AnimationStepGetBool(const FlxAnimationStep& step, const FString& name) { + FlxAnimationField field = FindAnimationField(step, name); + if (field.Type != ElxAnimValueType::BOOLEAN) return false; + return field.X == 1.0; +} + FlxAnimationStepView FlxAnimQueueDecoder::ReadStep() { FlxAnimationStepView result; result.Hash = Decoder.read_uint64(); diff --git a/Source/Integration/AnimQueue.h b/Source/Integration/AnimQueue.h index c773bc32..3673796c 100644 --- a/Source/Integration/AnimQueue.h +++ b/Source/Integration/AnimQueue.h @@ -111,12 +111,25 @@ class INTEGRATION_API UlxAnimationStepLibrary : public UObject GENERATED_BODY() public: - UFUNCTION(BlueprintCallable, BlueprintPure, Category = Tangibles) + UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex) static FString AnimationStepDebugString(const FlxAnimationStep& step); - UFUNCTION(BlueprintCallable, Category = Tangibles) + UFUNCTION(BlueprintCallable, Category = Luprex) static void UnpackAnimationStep(const FlxAnimationStep& step, - const FString& prefix, UObject* into, bool preclear = true); + const FString& VariableNamePrefix, UObject* into); + + UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex) + static FVector AnimationStepGetVector(const FlxAnimationStep& step, const FString& name); + + UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex) + static double AnimationStepGetFloat(const FlxAnimationStep& step, const FString& name); + + UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex) + static FString AnimationStepGetString(const FlxAnimationStep& step, const FString& name); + + UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex) + static bool AnimationStepGetBool(const FlxAnimationStep& step, const FString& name); + }; ////////////////////////////////////////////////