diff --git a/Content/Characters/Mannequins/Animations/ABP_Manny.uasset b/Content/Characters/Mannequins/Animations/ABP_Manny.uasset index af2b0f80..63f76caa 100644 --- a/Content/Characters/Mannequins/Animations/ABP_Manny.uasset +++ b/Content/Characters/Mannequins/Animations/ABP_Manny.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:10ac0617f269247f7a496f04f058f16f2c52a80e8207b9030126b5cecce10695 -size 430672 +oid sha256:ecf396c3199b1c670e4ff6616cb34e5a1b9dc034021d6d910eb7347fecb0200e +size 413277 diff --git a/Content/Tangibles/TAN_Character.uasset b/Content/Tangibles/TAN_Character.uasset index 2ae6d9c3..75f930ad 100644 --- a/Content/Tangibles/TAN_Character.uasset +++ b/Content/Tangibles/TAN_Character.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cddebb69e3efcb0fcb326fd24c7d8200e392bb9e9a80836679a02018beb1c058 -size 345222 +oid sha256:982ad39fdafc41fbe887b86e4e2a7a21f8491e1a4c81b7852301d22eb608b1ad +size 342981 diff --git a/Source/Integration/ScriptedAnimation.h b/Source/Integration/ScriptedAnimation.h index 856f4c3b..c902b514 100644 --- a/Source/Integration/ScriptedAnimation.h +++ b/Source/Integration/ScriptedAnimation.h @@ -1,3 +1,6 @@ + +#pragma once + #include "CoreMinimal.h" // #include "Kismet/KismetSystemLibrary.h" // #include "CommonTypes.h" diff --git a/Source/Integration/Tangible.cpp b/Source/Integration/Tangible.cpp index 23f1c08e..0d7005e6 100644 --- a/Source/Integration/Tangible.cpp +++ b/Source/Integration/Tangible.cpp @@ -89,26 +89,28 @@ void UlxTangible::SetActorBlueprint(const FString &XName) { // Create the actor at the specified location even if there's something in the way. params.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; - // Normally, SpawnActor runs the BeginPlay entry point. We - // want to delay that until after we've had a chance to set - // up the TangibleComponent. - params.bDeferConstruction = true; + // Spawn the actor even if it collides with something. params.bNoFail = true; + params.bDeferConstruction = true; + + // This pre-spawn initialization will inject the tangible component into the actor. + UlxTangible *ThisTangible = this; + params.CustomPreSpawnInitalization = [ThisTangible](AActor* A) + { + UActorComponent* ac = A->AddComponentByClass(UlxTangibleComponent::StaticClass(), false, FTransform::Identity, false); + UlxTangibleComponent* tc = Cast(ac); + check(tc != nullptr); + tc->Tangible = ThisTangible; + }; + UE_LOG(LogLuprexIntegration, Display, TEXT("Creating Actor: %s"), *params.Name.ToString()); AActor* a = w->SpawnActor(blueprint, &transform, params); check(a != nullptr); + CurrentActor = a; // Make sure the label and the name are the same. a->SetActorLabel(params.Name.ToString()); - // Insert a TangibleComponent into the actor. - // Link the actor to its tangible, and the tangible to its actor. - UActorComponent* ac = a->AddComponentByClass(UlxTangibleComponent::StaticClass(), false, FTransform::Identity, false); - UlxTangibleComponent* tc = Cast(ac); - check(tc != nullptr); - tc->Tangible = this; - CurrentActor = a; - // This executes the BeginPlay entry point. We have to do this here // because we deferred it in SpawnActor. a->FinishSpawning(transform, true); @@ -248,6 +250,18 @@ bool UlxTangible::AnimationStepIsFinished(AActor *target, const FlxAnimationStep return tan->AnimTracker.IsFinished(step.Hash); } +UlxScriptedAnimations *UlxTangible::GetScriptedAnimations(AActor *Target) +{ + UlxTangible *tan = GetActorTangibleOrLog(Target); + if (tan == nullptr) return nullptr; + if (tan->ScriptedAnimations == nullptr) + { + tan->ScriptedAnimations = NewObject(); + } + return tan->ScriptedAnimations; +} + + FString UlxTangible::GetTangiblePlane(AActor* target) { UlxTangible *tan = GetActorTangibleOrLog(target); if (tan == nullptr) return TEXT(""); diff --git a/Source/Integration/Tangible.h b/Source/Integration/Tangible.h index a0a4d68c..009b5e09 100644 --- a/Source/Integration/Tangible.h +++ b/Source/Integration/Tangible.h @@ -5,6 +5,7 @@ #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "AnimQueue.h" +#include "ScriptedAnimation.h" #include "Tangible.generated.h" @@ -45,7 +46,7 @@ public: // The tangible ID. UPROPERTY() - uint64 TangibleId; + uint64 TangibleId = 0; UPROPERTY() TWeakObjectPtr CurrentActor; @@ -54,23 +55,27 @@ public: UPROPERTY() FString ActorBlueprintName; + // This is + UPROPERTY() + UlxScriptedAnimations *ScriptedAnimations = nullptr; + // Animation tracker FlxAnimTracker AnimTracker; // Animation that is waiting to be finished. - uint64 PendingAnimationHash; + uint64 PendingAnimationHash = 0; // When do we timeout the pending animation. - double PendingAnimationTimeout; + double PendingAnimationTimeout = 0.0; // Current Plane. FName Plane; // True if luprex thinks this object is Near the player. - bool NearAccordingToLuprex; + bool NearAccordingToLuprex = false; // True if unreal thinks this object is Near the player. - bool NearAccordingToUnreal; + bool NearAccordingToUnreal = false; // Delete the current actor. // @@ -157,6 +162,9 @@ public: UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "Target", ExpandBoolAsExecs="ReturnValue"), Category = "Luprex|Animation Queue") static bool AnimationStepIsFinished(AActor *Target, const FlxAnimationStep &Step); + UFUNCTION(BlueprintPure, Meta = (DefaultToSelf = "Target"), Category = "Luprex|Scripted Animations") + static UlxScriptedAnimations *GetScriptedAnimations(AActor *Target); + UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = "Luprex|Tangible") static FString GetTangiblePlane(AActor* target);