From 334a95481d078887e22768ef435fa3b3ff53125f Mon Sep 17 00:00:00 2001 From: teppy999 Date: Mon, 9 Oct 2023 14:59:48 -0400 Subject: [PATCH] Checking everything in --- Content/TangibleActor.uasset | 4 ++-- Source/Integration/AnimQueue.cpp | 34 ++++++++++++++++++++++++++++---- Source/Integration/AnimQueue.h | 13 ++++++++++++ Source/Integration/Tangible.cpp | 8 ++++++-- Source/Integration/Tangible.h | 3 ++- 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/Content/TangibleActor.uasset b/Content/TangibleActor.uasset index 3a1da417..24cba782 100644 --- a/Content/TangibleActor.uasset +++ b/Content/TangibleActor.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e99102328387901e912868879c8f206986da80d8e38ba0352da7b12df46400b0 -size 160277 +oid sha256:90b49cd7987f58dbe07e6c7af9896ce38633e1212eef5fe3b7132b12e13df4d7 +size 160465 diff --git a/Source/Integration/AnimQueue.cpp b/Source/Integration/AnimQueue.cpp index 7301d4ab..2fca5ce0 100644 --- a/Source/Integration/AnimQueue.cpp +++ b/Source/Integration/AnimQueue.cpp @@ -91,15 +91,13 @@ void UlxAnimationStepLibrary::UnpackAnimationStep(UObject* into, const FlxAnimat step.Unpack(prefix, into, true); } -static FlxAnimationField FindAnimationField(const FlxAnimationStep& step, const FString& name) { +static FlxAnimationField FindAnimationFieldLL(const FlxAnimationStep& step, std::string_view 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) { + if (result.Name == name) { return result; } } @@ -107,6 +105,34 @@ static FlxAnimationField FindAnimationField(const FlxAnimationStep& step, const return result; } +static FlxAnimationField FindAnimationField(const FlxAnimationStep& step, const FString& name) { + FTCHARToUTF8 utf8name(name); + std::string_view uname(utf8name.Get(), utf8name.Length()); + return FindAnimationFieldLL(step, uname); +} + +void FlxAnimationStep::AutoUpdateXYZ(AActor *actor) const { + FlxAnimationField xyz = FindAnimationFieldLL(*this, "xyz"); + if (xyz.Type == ElxAnimValueType::XYZ) { + actor->SetActorLocation(FVector(xyz.X, xyz.Y, xyz.Z)); + } +} + +void FlxAnimationStep::AutoUpdateFacing(AActor *actor) const { + FlxAnimationField facing = FindAnimationFieldLL(*this, "facing"); + if (facing.Type == ElxAnimValueType::NUMBER) { + actor->SetActorRotation(FRotator(0, facing.X, 0)); + } +} + +void FlxAnimationStep::AutoUpdatePlane(FName *planep) const { + FlxAnimationField plane = FindAnimationFieldLL(*this, "plane"); + if (plane.Type == ElxAnimValueType::STRING) { + FString pname(plane.S.size(), (const UTF8CHAR*)(plane.S.data())); + *planep = FName(pname); + } +} + bool UlxAnimationStepLibrary::AnimationStepIsIdle(const FlxAnimationStep &step) { return step.Finished; } diff --git a/Source/Integration/AnimQueue.h b/Source/Integration/AnimQueue.h index 1f5d8188..02ab3300 100644 --- a/Source/Integration/AnimQueue.h +++ b/Source/Integration/AnimQueue.h @@ -75,6 +75,19 @@ public: // unpacking the animation step. // bool Unpack(const FString& prefix, UObject* into, bool preclear = true) const; + + // Auto-Execute + // + // These functions automatically update certain actor + // properties: + // + // AutoUpdateXYZ(AActor *actor); // uses 'xyz' keyword + // AutoUpdateFacing(AActor *actor); // uses 'facing' keyword. + // AutoUpdatePlane(FName *plane); // uses 'plane' keyword + // + void AutoUpdateXYZ(AActor *actor) const; + void AutoUpdateFacing(AActor *actor) const; + void AutoUpdatePlane(FName *plane) const; }; //////////////////////////////////////////////// diff --git a/Source/Integration/Tangible.cpp b/Source/Integration/Tangible.cpp index 4ec72d9f..259776a2 100644 --- a/Source/Integration/Tangible.cpp +++ b/Source/Integration/Tangible.cpp @@ -115,8 +115,12 @@ void UlxTangible::GetCurrentAnimation(AActor *target, FlxAnimationStep &step) { step = GetActorTangible(target)->AnimTracker.GetCurrentAnimation(); } -void UlxTangible::FinishedAnimation(AActor *target, const FlxAnimationStep &step) { - GetActorTangible(target)->AnimTracker.FinishedAnimation(step.Hash); +void UlxTangible::FinishedAnimation(AActor *target, const FlxAnimationStep &step, bool autoxyz, bool autofacing, bool autoplane) { + UlxTangible *tan = GetActorTangible(target); + if (autoxyz) step.AutoUpdateXYZ(target); + if (autofacing) step.AutoUpdateFacing(target); + if (autoplane) step.AutoUpdatePlane(&(tan->Plane)); + tan->AnimTracker.FinishedAnimation(step.Hash); } FString UlxTangible::GetTangiblePlane(AActor* target) { diff --git a/Source/Integration/Tangible.h b/Source/Integration/Tangible.h index fc7e9e79..4545a33b 100644 --- a/Source/Integration/Tangible.h +++ b/Source/Integration/Tangible.h @@ -167,7 +167,8 @@ public: static void GetCurrentAnimation(AActor *target, FlxAnimationStep &step); UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex) - static void FinishedAnimation(AActor *target, const FlxAnimationStep &step); + static void FinishedAnimation(AActor *target, const FlxAnimationStep &step, + bool AutoUpdateXYZ = true, bool AutoUpdateFacing = true, bool AutoUpdatePlane = true); UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex) static FString GetTangiblePlane(AActor* target);