diff --git a/Source/Integration/IntegrationGameModeBase.cpp b/Source/Integration/IntegrationGameModeBase.cpp index e0f7fbdf..1904153f 100644 --- a/Source/Integration/IntegrationGameModeBase.cpp +++ b/Source/Integration/IntegrationGameModeBase.cpp @@ -194,7 +194,7 @@ void AIntegrationGameModeBase::BeginPlay() // Create a tangible. TangibleManager.Init(GetWorld(), ClassTangibleActor); - //TangibleManager.MakeTangible(123); + TangibleManager.MakeTangible(123); } void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason) diff --git a/Source/Integration/TangibleManager.cpp b/Source/Integration/TangibleManager.cpp index 6264c243..6950625f 100644 --- a/Source/Integration/TangibleManager.cpp +++ b/Source/Integration/TangibleManager.cpp @@ -3,37 +3,37 @@ #include "TangibleManager.h" -//using AActorPtr = AActor*; +using AActorPtr = AActor*; void FTangibleManager::Init(UWorld *world, UClass* tanact) { World = world; ClassTangibleActor = tanact; } -//AActorPtr FTangibleManager::GetTangible(int64 id) { -// AActorPtr *p = IdToActor.Find(id); -// if (p == nullptr) { -// return nullptr; -// } else { -// return *p; -// } -//} -// -//// Get the tangible if it exists, otherwise create it. -//AActorPtr FTangibleManager::MakeTangible(int64 id) { -// AActorPtr& p = IdToActor.FindOrAdd(id); -// if (p == nullptr) { -// FVector location; -// FRotator rotation; -// FActorSpawnParameters params; -// p = w->SpawnActor(ClassTangibleActor, &location, &rotation, params); -// assert(p != nullptr); -// } -// return p; -//} -// -//// Delete the tangible. -//void FTangibleManager::DeleteTangible(int64 id) { -// // IMPLEMENT ME -//} +AActorPtr FTangibleManager::GetTangible(int64 id) { + AActorPtr *p = IdToActor.Find(id); + if (p == nullptr) { + return nullptr; + } else { + return *p; + } +} + +// Get the tangible if it exists, otherwise create it. +AActorPtr FTangibleManager::MakeTangible(int64 id) { + AActorPtr& p = IdToActor.FindOrAdd(id); + if (p == nullptr) { + FVector location; + FRotator rotation; + FActorSpawnParameters params; + p = World->SpawnActor(ClassTangibleActor, &location, &rotation, params); + check(p != nullptr); + } + return p; +} + +// Delete the tangible. +void FTangibleManager::DeleteTangible(int64 id) { + // IMPLEMENT ME +} diff --git a/Source/Integration/TangibleManager.h b/Source/Integration/TangibleManager.h index 156168c5..6b358af5 100644 --- a/Source/Integration/TangibleManager.h +++ b/Source/Integration/TangibleManager.h @@ -22,21 +22,21 @@ public: UPROPERTY() TSubclassOf ClassTangibleActor; - //// Given a tangible ID, look up actor pointer (or NULL if actor was deleted) - //UPROPERTY() - //TMap IdToActor; + // Given a tangible ID, look up actor pointer (or NULL if actor was deleted) + UPROPERTY() + TMap IdToActor; public: // Initialize the tangible manager. // void Init(UWorld *world, UClass* tanact); - //// Get the tangible if it exists, otherwise return NULL - //AActor* GetTangible(int64 id); + // Get the tangible if it exists, otherwise return NULL + AActor* GetTangible(int64 id); - //// Get the tangible if it exists, otherwise create it. - //AActor* MakeTangible(int64 id); + // Get the tangible if it exists, otherwise create it. + AActor* MakeTangible(int64 id); - //// Delete the tangible. - //void DeleteTangible(int64 id); + // Delete the tangible. + void DeleteTangible(int64 id); };