55 lines
1.1 KiB
C++
55 lines
1.1 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "TangibleManager.h"
|
|
|
|
using AActorPtr = AActor*;
|
|
|
|
FTangibleManager::FTangibleManager() {
|
|
World = nullptr;
|
|
ClassTangibleActor = nullptr;
|
|
Actor = 0;
|
|
Near = IdView();
|
|
}
|
|
|
|
void FTangibleManager::Init(UWorld *world, UClass* tanact) {
|
|
World = world;
|
|
ClassTangibleActor = tanact;
|
|
Actor = 0;
|
|
Near = IdView();
|
|
}
|
|
|
|
AActorPtr FTangibleManager::GetTangible(int64 id) {
|
|
AActorPtr *p = IdToActor.Find(id);
|
|
if (p == nullptr) {
|
|
return nullptr;
|
|
} else {
|
|
return *p;
|
|
}
|
|
}
|
|
|
|
AActorPtr FTangibleManager::MakeTangible(int64 id) {
|
|
AActorPtr& p = IdToActor.FindOrAdd(id);
|
|
if (p == nullptr) {
|
|
FVector location(0,0,0);
|
|
FRotator rotation(0, 0, 0);
|
|
FActorSpawnParameters params;
|
|
p = World->SpawnActor(ClassTangibleActor, &location, &rotation, params);
|
|
check(p != nullptr);
|
|
}
|
|
return p;
|
|
}
|
|
|
|
void FTangibleManager::DeleteTangible(int64 id) {
|
|
// IMPLEMENT ME
|
|
}
|
|
|
|
FTangibleManager::IdArray FTangibleManager::GetLive() {
|
|
IdArray result;
|
|
result.SetNum(IdToActor.Num());
|
|
int next = 0;
|
|
for (auto &pair : IdToActor) {
|
|
result[next++] = pair.Key;
|
|
}
|
|
return result;
|
|
} |