Some progress toward tangible GC:
This commit is contained in:
@@ -121,22 +121,17 @@ void AIntegrationGameModeBase::MaybeTriggerUpdateTask(float deltaseconds) {
|
|||||||
#pragma optimize("", off)
|
#pragma optimize("", off)
|
||||||
|
|
||||||
void AIntegrationGameModeBase::UpdateTangibles() {
|
void AIntegrationGameModeBase::UpdateTangibles() {
|
||||||
|
using TanArray = UlxTangibleManager::TanArray;
|
||||||
if (!Playing) return;
|
if (!Playing) return;
|
||||||
FlxLockedWrapper w(LockableWrapper);
|
FlxLockedWrapper w(LockableWrapper);
|
||||||
int64 actor = w.GetActor();
|
int64 player = w.GetActor();
|
||||||
TangibleManager->SetPlayer(actor);
|
TangibleManager->UpdateNear(w.GetNear(player, 100, 100, 100));
|
||||||
IdView near = w.GetNear(actor, 100, 100, 100);
|
TanArray alltans = TangibleManager->GetAllTangibles();
|
||||||
TangibleManager->SetNear(near);
|
IdArray allids = TangibleManager->GetIds(alltans);
|
||||||
for (int64 id : near) {
|
StringViewVec allqueues = w.GetAnimationQueues(allids);
|
||||||
TangibleManager->MakeTangible(id);
|
for (int i = 0; i < alltans.Num(); i++) {
|
||||||
}
|
UlxTangible *t = alltans[i];
|
||||||
// Update animation queues of live tangibles.
|
t->AnimTracker.Update(allqueues[i]);
|
||||||
IdArray tanids = TangibleManager->GetLive();
|
|
||||||
StringViewVec aqueues = w.GetAnimationQueues(tanids);
|
|
||||||
for (int i = 0; i < tanids.Num(); i++) {
|
|
||||||
uint64_t tanid = tanids[i];
|
|
||||||
UlxTangible *t = TangibleManager->GetTangible(tanid);
|
|
||||||
t->AnimTracker.Update(aqueues[i]);
|
|
||||||
TArray<uint64> aborted = t->AnimTracker.GetAborted();
|
TArray<uint64> aborted = t->AnimTracker.GetAborted();
|
||||||
for (uint64 hash : aborted) {
|
for (uint64 hash : aborted) {
|
||||||
IlxTangibleInterface::Execute_AbortAnimation(t->GetActor(), hash);
|
IlxTangibleInterface::Execute_AbortAnimation(t->GetActor(), hash);
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
UlxTangible::UlxTangible()
|
UlxTangible::UlxTangible()
|
||||||
{
|
{
|
||||||
|
TangibleId = -1;
|
||||||
|
NearAccordingToLuprex = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UlxTangible::Init(UlxTangibleManager* tm, int64 id)
|
void UlxTangible::Init(UlxTangibleManager* tm, int64 id)
|
||||||
|
|||||||
@@ -6,27 +6,24 @@
|
|||||||
#include "DebugPrint.h"
|
#include "DebugPrint.h"
|
||||||
|
|
||||||
using namespace DebugPrint;
|
using namespace DebugPrint;
|
||||||
|
using TanArray = UlxTangibleManager::TanArray;
|
||||||
|
using IdArray = UlxTangibleManager::IdArray;
|
||||||
|
|
||||||
UlxTangibleManager::UlxTangibleManager() {
|
UlxTangibleManager::UlxTangibleManager() {
|
||||||
World = nullptr;
|
World = nullptr;
|
||||||
ClassTangibleActor = nullptr;
|
ClassTangibleActor = nullptr;
|
||||||
Player = 0;
|
|
||||||
Near = IdView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UlxTangibleManager::Init(UWorld* world, UClass* tanact) {
|
void UlxTangibleManager::Init(UWorld* world, UClass* tanact) {
|
||||||
World = world;
|
World = world;
|
||||||
ClassTangibleActor = tanact;
|
ClassTangibleActor = tanact;
|
||||||
Player = 0;
|
|
||||||
Near = IdView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UlxTangible* UlxTangibleManager::GetTangible(int64 id) {
|
UlxTangible* UlxTangibleManager::GetTangible(int64 id) const {
|
||||||
UlxTangible** p = IdToTangible.Find(id);
|
UlxTangible*const* p = IdToTangible.Find(id);
|
||||||
if (p == nullptr) {
|
if (p == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return *p;
|
return *p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,12 +46,34 @@ void UlxTangibleManager::DeleteTangible(int64 id) {
|
|||||||
// IMPLEMENT ME
|
// IMPLEMENT ME
|
||||||
}
|
}
|
||||||
|
|
||||||
UlxTangibleManager::IdArray UlxTangibleManager::GetLive() {
|
TanArray UlxTangibleManager::GetAllTangibles() const {
|
||||||
IdArray result;
|
TanArray result;
|
||||||
result.SetNum(IdToTangible.Num());
|
result.SetNum(IdToTangible.Num());
|
||||||
int next = 0;
|
int next = 0;
|
||||||
for (auto& pair : IdToTangible) {
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ class INTEGRATION_API UlxTangibleManager : public UObject
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Import these types into our Namespace.
|
// Types used frequently.
|
||||||
using IdArray = CommonTypes::IdArray;
|
|
||||||
using IdView = CommonTypes::IdView;
|
using IdView = CommonTypes::IdView;
|
||||||
|
using IdArray = CommonTypes::IdArray;
|
||||||
|
using TanArray = TArray<UlxTangible*>;
|
||||||
|
|
||||||
// A pointer to our world.
|
// A pointer to our world.
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
@@ -31,12 +32,6 @@ public:
|
|||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TMap<int64, UlxTangible*> IdToTangible;
|
TMap<int64, UlxTangible*> IdToTangible;
|
||||||
|
|
||||||
// Player's tangible Id.
|
|
||||||
int64 Player;
|
|
||||||
|
|
||||||
// Tangibles near the actor.
|
|
||||||
IdView Near;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UlxTangibleManager();
|
UlxTangibleManager();
|
||||||
|
|
||||||
@@ -49,28 +44,30 @@ public:
|
|||||||
UWorld* GetWorld() const override { return World.Get(); }
|
UWorld* GetWorld() const override { return World.Get(); }
|
||||||
|
|
||||||
// Get the tangible if it exists, otherwise return NULL
|
// Get the tangible if it exists, otherwise return NULL
|
||||||
UlxTangible* GetTangible(int64 id);
|
//
|
||||||
|
UlxTangible* GetTangible(int64 id) const;
|
||||||
|
|
||||||
// Get the tangible if it exists, otherwise create it.
|
// Get the tangible if it exists, otherwise create it.
|
||||||
|
//
|
||||||
UlxTangible* MakeTangible(int64 id);
|
UlxTangible* MakeTangible(int64 id);
|
||||||
|
|
||||||
// Delete the tangible.
|
// Delete the tangible.
|
||||||
|
//
|
||||||
void DeleteTangible(int64 id);
|
void DeleteTangible(int64 id);
|
||||||
|
|
||||||
// Get/Set the Id of the actor.
|
// Get an array of all tangibles.
|
||||||
//
|
//
|
||||||
int64 GetPlayer() const { return Player; };
|
TanArray GetAllTangibles() const;
|
||||||
void SetPlayer(int64 id) { Player = id; }
|
|
||||||
|
|
||||||
// Get/Set the list of tangibles near the player, according to Luprex.
|
// Update the 'NearAccordingToLuprex' flags.
|
||||||
//
|
//
|
||||||
IdView GetNear() const { return Near; }
|
// Also creates any tangibles that are in the near-list,
|
||||||
void SetNear(IdView near) { Near = near; }
|
// if they don't already exist.
|
||||||
|
//
|
||||||
|
void UpdateNear(IdView near);
|
||||||
|
|
||||||
// Get the Live list.
|
// Given an array of tangibles, return an array of tangible Ids.
|
||||||
//
|
//
|
||||||
// Efficiency note: this makes a copy of the array.
|
static IdArray GetIds(const TanArray &tans);
|
||||||
//
|
|
||||||
IdArray GetLive();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user