Lots of work on several unrelated things.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include "TangibleManager.h"
|
||||
#include "LuprexGameModeBase.h"
|
||||
|
||||
#define DEFAULT_BLUEPRINT (TEXT("TangibleStaticMesh"))
|
||||
#define DEFAULT_BLUEPRINT (TEXT("StaticMesh"))
|
||||
|
||||
UlxTangible::UlxTangible()
|
||||
{
|
||||
@@ -24,17 +24,18 @@ void UlxTangible::Init(UlxTangibleManager* tm, int64 id)
|
||||
}
|
||||
|
||||
#pragma optimize("", off)
|
||||
void UlxTangible::SetActorBlueprint(const FString &name) {
|
||||
void UlxTangible::SetActorBlueprint(const FString &XName) {
|
||||
FString Name = XName.ToLower();
|
||||
|
||||
// If we're already of the right class, do nothing.
|
||||
if (ActorBlueprintName == name) {
|
||||
if (ActorBlueprintName == Name) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
UClass *blueprint = Manager->GetTangibleClass(Name);
|
||||
if (blueprint == nullptr)
|
||||
{
|
||||
blueprint = Manager->GetTangibleClass(DEFAULT_BLUEPRINT);
|
||||
check(blueprint != nullptr);
|
||||
}
|
||||
@@ -62,13 +63,16 @@ void UlxTangible::SetActorBlueprint(const FString &name) {
|
||||
}
|
||||
|
||||
// Update the blueprint name
|
||||
ActorBlueprintName = name;
|
||||
ActorBlueprintName = Name;
|
||||
|
||||
// Now create a new actor, unless the BP is nullptr.
|
||||
if (blueprint != nullptr) {
|
||||
UWorld* w = Manager->GetWorld();
|
||||
FActorSpawnParameters params;
|
||||
|
||||
// Give the new actor a reasonable name.
|
||||
params.Name = FName(*FString::Printf(TEXT("%s_%ld"), *Name, TangibleId));
|
||||
|
||||
// Currently, the actor is spawned at (0,0,0), which is not good.
|
||||
// We should spawn at the actor's current location. I'll get to it
|
||||
// eventually.
|
||||
@@ -86,6 +90,9 @@ void UlxTangible::SetActorBlueprint(const FString &name) {
|
||||
AActor* a = w->SpawnActor(blueprint, &transform, params);
|
||||
check(a != nullptr);
|
||||
|
||||
// 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);
|
||||
|
||||
Reference in New Issue
Block a user