More refactoring of scripted animations: Tangibles now contain ScriptedAnimation pointers.
This commit is contained in:
@@ -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<UlxTangibleComponent>(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<UlxTangibleComponent>(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<UlxScriptedAnimations>();
|
||||
}
|
||||
return tan->ScriptedAnimations;
|
||||
}
|
||||
|
||||
|
||||
FString UlxTangible::GetTangiblePlane(AActor* target) {
|
||||
UlxTangible *tan = GetActorTangibleOrLog(target);
|
||||
if (tan == nullptr) return TEXT("");
|
||||
|
||||
Reference in New Issue
Block a user