Can now specify bp= in the animation queue, and it works
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
#include "Tangible.h"
|
||||
#include "TangibleManager.h"
|
||||
|
||||
#define DEFAULT_BLUEPRINT (TEXT("TangibleStaticMesh"))
|
||||
|
||||
UlxTangible::UlxTangible()
|
||||
{
|
||||
Manager = nullptr;
|
||||
TangibleId = -1;
|
||||
CurrentActor = nullptr;
|
||||
ActorBlueprint = nullptr;
|
||||
ActorBlueprintName = TEXT("");
|
||||
NearAccordingToLuprex = false;
|
||||
NearAccordingToUnreal = false;
|
||||
}
|
||||
@@ -20,19 +22,20 @@ void UlxTangible::Init(UlxTangibleManager* tm, int64 id)
|
||||
TangibleId = id;
|
||||
}
|
||||
|
||||
bool UlxTangible::BlueprintIsTangible(TSubclassOf<AActor> bp) {
|
||||
if (bp == nullptr) return true;
|
||||
return bp->ImplementsInterface(UlxTangibleInterface::StaticClass());
|
||||
}
|
||||
|
||||
void UlxTangible::SetActorBlueprintClass(TSubclassOf<AActor> bp) {
|
||||
void UlxTangible::SetActorBlueprint(const FString &name) {
|
||||
// If we're already of the right class, do nothing.
|
||||
if (ActorBlueprint == bp) {
|
||||
if (ActorBlueprintName == name) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Sanity check the blueprint. Nullptr is allowed.
|
||||
check(BlueprintIsTangible(bp));
|
||||
// Get the blueprint.
|
||||
// If the blueprint doesn't exist, or doesn't implement
|
||||
// TangibleInterface, then use the fallback blueprint.
|
||||
UClass *blueprint = Manager->GetTangibleClass(name);
|
||||
if ((!name.IsEmpty()) && (blueprint == nullptr)) {
|
||||
blueprint = Manager->GetTangibleClass(DEFAULT_BLUEPRINT);
|
||||
check(blueprint != nullptr);
|
||||
}
|
||||
|
||||
// If there's already an actor, delete it.
|
||||
if (CurrentActor != nullptr) {
|
||||
@@ -50,17 +53,17 @@ void UlxTangible::SetActorBlueprintClass(TSubclassOf<AActor> bp) {
|
||||
CurrentActor->Destroy();
|
||||
}
|
||||
|
||||
// Update the blueprint reference.
|
||||
ActorBlueprint = bp;
|
||||
// Update the blueprint name
|
||||
ActorBlueprintName = name;
|
||||
|
||||
// Now create a new actor, unless the BP is nullptr.
|
||||
if (ActorBlueprint != nullptr) {
|
||||
if (blueprint != nullptr) {
|
||||
// Create the actor.
|
||||
FActorSpawnParameters params;
|
||||
FVector location(0, 0, 0);
|
||||
FRotator rotation(0, 0, 0);
|
||||
UWorld* w = Manager->GetWorld();
|
||||
AActor* a = w->SpawnActor(ActorBlueprint, &location, &rotation, params);
|
||||
AActor* a = w->SpawnActor(blueprint, &location, &rotation, params);
|
||||
|
||||
// Insert a TangibleComponent into the actor.
|
||||
UActorComponent* ac = a->AddComponentByClass(UlxTangibleComponent::StaticClass(), false, FTransform::Identity, false);
|
||||
@@ -80,6 +83,9 @@ void UlxTangible::UpdateAnimationQueue(std::string_view aq) {
|
||||
if (limit == 0) break;
|
||||
limit -= 1;
|
||||
AnimTracker.ClearChanged();
|
||||
FString blueprint = AnimTracker.GetCurrentBlueprintName();
|
||||
if (blueprint.IsEmpty()) blueprint = DEFAULT_BLUEPRINT;
|
||||
SetActorBlueprint(blueprint);
|
||||
IlxTangibleInterface::Execute_AnimationStateChanged(GetActor());
|
||||
}
|
||||
}
|
||||
@@ -93,11 +99,11 @@ FVector UlxTangible::GetLocation() const {
|
||||
}
|
||||
|
||||
void UlxTangible::Destroy() {
|
||||
SetActorBlueprintClass(nullptr);
|
||||
SetActorBlueprint("");
|
||||
Manager = nullptr;
|
||||
TangibleId = -1;
|
||||
CurrentActor = nullptr;
|
||||
ActorBlueprint = nullptr;
|
||||
ActorBlueprintName = "";
|
||||
AnimTracker.Clear();
|
||||
NearAccordingToLuprex = false;
|
||||
NearAccordingToUnreal = false;
|
||||
|
||||
Reference in New Issue
Block a user