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
|
|
|
|
2023-09-06 23:25:37 -04:00
|
|
|
FTangibleManager::FTangibleManager() {
|
|
|
|
|
World = nullptr;
|
|
|
|
|
ClassTangibleActor = nullptr;
|
|
|
|
|
Actor = 0;
|
2023-09-07 23:50:49 -04:00
|
|
|
Near = IdView();
|
2023-09-06 23:25:37 -04:00
|
|
|
}
|
|
|
|
|
|
2023-09-02 01:39:35 -04:00
|
|
|
void FTangibleManager::Init(UWorld *world, UClass* tanact) {
|
|
|
|
|
World = world;
|
|
|
|
|
ClassTangibleActor = tanact;
|
2023-09-06 23:25:37 -04:00
|
|
|
Actor = 0;
|
2023-09-07 23:50:49 -04:00
|
|
|
Near = IdView();
|
2023-09-02 01:39:35 -04:00
|
|
|
}
|
|
|
|
|
|
2023-09-15 00:01:41 -04:00
|
|
|
UTangible *FTangibleManager::GetTangible(int64 id) {
|
|
|
|
|
UTangible **p = IdToTangible.Find(id);
|
2023-09-02 01:43:44 -04:00
|
|
|
if (p == nullptr) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
} else {
|
|
|
|
|
return *p;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 00:01:41 -04:00
|
|
|
UTangible *FTangibleManager::MakeTangible(int64 id) {
|
|
|
|
|
UTangible *& p = IdToTangible.FindOrAdd(id);
|
2023-09-02 01:43:44 -04:00
|
|
|
if (p == nullptr) {
|
2023-09-06 23:25:37 -04:00
|
|
|
FVector location(0,0,0);
|
|
|
|
|
FRotator rotation(0, 0, 0);
|
2023-09-02 01:43:44 -04:00
|
|
|
FActorSpawnParameters params;
|
2023-09-15 00:01:41 -04:00
|
|
|
AActor* a = World->SpawnActor(ClassTangibleActor, &location, &rotation, params);
|
|
|
|
|
check(a != nullptr);
|
|
|
|
|
check(a->GetClass()->ImplementsInterface(UTangibleInterface::StaticClass()));
|
|
|
|
|
p = NewObject<UTangible>();
|
|
|
|
|
p->Init(a);
|
2023-09-02 01:43:44 -04:00
|
|
|
}
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FTangibleManager::DeleteTangible(int64 id) {
|
|
|
|
|
// IMPLEMENT ME
|
|
|
|
|
}
|
2023-09-07 23:50:49 -04:00
|
|
|
|
|
|
|
|
FTangibleManager::IdArray FTangibleManager::GetLive() {
|
|
|
|
|
IdArray result;
|
2023-09-15 00:01:41 -04:00
|
|
|
result.SetNum(IdToTangible.Num());
|
2023-09-07 23:50:49 -04:00
|
|
|
int next = 0;
|
2023-09-15 00:01:41 -04:00
|
|
|
for (auto &pair : IdToTangible) {
|
2023-09-07 23:50:49 -04:00
|
|
|
result[next++] = pair.Key;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|