81 lines
1.9 KiB
C++
81 lines
1.9 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "TangibleManager.h"
|
|
#include "Tangible.h"
|
|
#include "DebugPrint.h"
|
|
|
|
using namespace DebugPrint;
|
|
using TanArray = UlxTangibleManager::TanArray;
|
|
using IdArray = UlxTangibleManager::IdArray;
|
|
|
|
UlxTangibleManager::UlxTangibleManager() {
|
|
World = nullptr;
|
|
ClassTangibleActor = nullptr;
|
|
}
|
|
|
|
void UlxTangibleManager::Init(UWorld* world, UClass* tanact) {
|
|
World = world;
|
|
ClassTangibleActor = tanact;
|
|
}
|
|
|
|
UlxTangible* UlxTangibleManager::GetTangible(int64 id) const {
|
|
UlxTangible*const* p = IdToTangible.Find(id);
|
|
if (p == nullptr) {
|
|
return nullptr;
|
|
} else {
|
|
return *p;
|
|
}
|
|
}
|
|
|
|
UlxTangible* UlxTangibleManager::MakeTangible(int64 id) {
|
|
UlxTangible*& t = IdToTangible.FindOrAdd(id);
|
|
if (t == nullptr) {
|
|
t = NewObject<UlxTangible>();
|
|
t->Init(this, id);
|
|
|
|
// TODO: fix this. The blueprint needs to be assigned
|
|
// during animation queue parsing, based on the animation
|
|
// queue keyword 'bp'.
|
|
t->SetActorBlueprintClass(ClassTangibleActor);
|
|
}
|
|
return t;
|
|
}
|
|
|
|
void UlxTangibleManager::DeleteTangible(int64 id) {
|
|
// IMPLEMENT ME
|
|
}
|
|
|
|
TanArray UlxTangibleManager::GetAllTangibles() const {
|
|
TanArray result;
|
|
result.SetNum(IdToTangible.Num());
|
|
int next = 0;
|
|
for (auto& pair : IdToTangible) {
|
|
result[next++] = pair.Value;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
void UlxTangibleManager::UpdateNear(IdView near) {
|
|
// Clear all the 'NearAccordingToLuprex' flags.
|
|
for (const auto& pair : IdToTangible) {
|
|
pair.Value->NearAccordingToLuprex = false;
|
|
}
|
|
// For every ID on the list, create it if it doesn't exist,
|
|
// mark it, and return it.
|
|
for (int64 id : near) {
|
|
UlxTangible* tan = MakeTangible(id);
|
|
tan->NearAccordingToLuprex = true;
|
|
}
|
|
}
|
|
|
|
IdArray UlxTangibleManager::GetIds(const TanArray &arr) {
|
|
IdArray result;
|
|
result.SetNum(arr.Num());
|
|
for (int i = 0; i < arr.Num(); i++) {
|
|
result[i] = arr[i]->TangibleId;
|
|
}
|
|
return result;
|
|
}
|
|
|