Files
integration/Source/Integration/TangibleManager.cpp

60 lines
1.3 KiB
C++
Raw Normal View History

2023-09-02 01:33:11 -04:00
// Fill out your copyright notice in the Description page of Project Settings.
#include "TangibleManager.h"
2023-09-15 00:01:41 -04:00
#include "TangibleInterface.h"
#include "DebugPrint.h"
2023-09-02 01:33:11 -04:00
2023-09-15 00:01:41 -04:00
using namespace DebugPrint;
2023-09-02 01:33:11 -04:00
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();
}
2023-09-15 13:28:18 -04:00
UlxTangible *FTangibleManager::GetTangible(int64 id) {
UlxTangible **p = IdToTangible.Find(id);
if (p == nullptr) {
return nullptr;
} else {
return *p;
}
}
2023-09-15 13:28:18 -04:00
UlxTangible *FTangibleManager::MakeTangible(int64 id) {
UlxTangible *& p = IdToTangible.FindOrAdd(id);
if (p == nullptr) {
FVector location(0,0,0);
FRotator rotation(0, 0, 0);
FActorSpawnParameters params;
2023-09-15 00:01:41 -04:00
AActor* a = World->SpawnActor(ClassTangibleActor, &location, &rotation, params);
check(a != nullptr);
2023-09-15 13:28:18 -04:00
check(a->GetClass()->ImplementsInterface(UlxTangibleInterface::StaticClass()));
p = NewObject<UlxTangible>();
2023-09-15 00:01:41 -04:00
p->Init(a);
}
return p;
}
void FTangibleManager::DeleteTangible(int64 id) {
// IMPLEMENT ME
}
FTangibleManager::IdArray FTangibleManager::GetLive() {
IdArray result;
2023-09-15 00:01:41 -04:00
result.SetNum(IdToTangible.Num());
int next = 0;
2023-09-15 00:01:41 -04:00
for (auto &pair : IdToTangible) {
result[next++] = pair.Key;
}
return result;
}