Some progress toward tangible GC:

This commit is contained in:
2023-09-26 19:26:09 -04:00
parent 0efd0dd3ad
commit 9116a7b8fe
4 changed files with 60 additions and 47 deletions

View File

@@ -6,27 +6,24 @@
#include "DebugPrint.h"
using namespace DebugPrint;
using TanArray = UlxTangibleManager::TanArray;
using IdArray = UlxTangibleManager::IdArray;
UlxTangibleManager::UlxTangibleManager() {
World = nullptr;
ClassTangibleActor = nullptr;
Player = 0;
Near = IdView();
}
void UlxTangibleManager::Init(UWorld* world, UClass* tanact) {
World = world;
ClassTangibleActor = tanact;
Player = 0;
Near = IdView();
}
UlxTangible* UlxTangibleManager::GetTangible(int64 id) {
UlxTangible** p = IdToTangible.Find(id);
UlxTangible* UlxTangibleManager::GetTangible(int64 id) const {
UlxTangible*const* p = IdToTangible.Find(id);
if (p == nullptr) {
return nullptr;
}
else {
} else {
return *p;
}
}
@@ -49,12 +46,34 @@ void UlxTangibleManager::DeleteTangible(int64 id) {
// IMPLEMENT ME
}
UlxTangibleManager::IdArray UlxTangibleManager::GetLive() {
IdArray result;
TanArray UlxTangibleManager::GetAllTangibles() const {
TanArray result;
result.SetNum(IdToTangible.Num());
int next = 0;
for (auto& pair : IdToTangible) {
result[next++] = pair.Key;
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;
}