Some light rearranging prior to AnimQueue stuff

This commit is contained in:
2023-09-07 23:50:49 -04:00
parent 5af9741cd5
commit ee0b37725e
7 changed files with 44 additions and 15 deletions

View File

View File

View File

@@ -0,0 +1,9 @@
#pragma once
namespace LuprexCommonTypes {
// Array of tangible IDs.
using IdArray = TArray<int64>;
// View of Array of tangible IDs.
using IdView = TArrayView<const int64>;
}

View File

@@ -38,9 +38,9 @@ int64 FLockedWrapper::GetActor() {
return Lockable.Wrapper.get_actor_id(Get());
}
FLockedWrapper::IdList FLockedWrapper::GetNear(int64 id, double rx, double ry, double rz) {
FLockedWrapper::IdView FLockedWrapper::GetNear(int64 id, double rx, double ry, double rz) {
uint32 size;
int64* data;
Lockable.Wrapper.get_tangibles_near(Get(), id, rx, ry, rz, &size, &data);
return IdList(data, size);
return IdView(data, size);
}

View File

@@ -2,6 +2,7 @@
#include "CoreMinimal.h"
#include "lpx-enginewrapper.hpp"
#include "CommonTypes.h"
// Class FLockableWrapper
//
@@ -22,7 +23,10 @@ class FLockedWrapper {
private:
FLockableWrapper& Lockable;
using IdList = TArrayView<const int64>;
public:
// Import these types into our Namespace.
using IdArray = LuprexCommonTypes::IdArray;
using IdView = LuprexCommonTypes::IdView;
public:
// The constructor of the FLockedWrapper claims the mutex.
@@ -66,8 +70,8 @@ public:
// Get the list of tangibles near the actor.
//
// This function is fast but not free. You should fetch this
// once per frame and then store the IdList somewhere (like
// once per frame and then store the IdView somewhere (like
// in the TangibleManager, for example).
//
IdList GetNear(int64 id, double rx, double ry, double rz);
IdView GetNear(int64 id, double rx, double ry, double rz);
};

View File

@@ -9,14 +9,14 @@ FTangibleManager::FTangibleManager() {
World = nullptr;
ClassTangibleActor = nullptr;
Actor = 0;
Near = IdList();
Near = IdView();
}
void FTangibleManager::Init(UWorld *world, UClass* tanact) {
World = world;
ClassTangibleActor = tanact;
Actor = 0;
Near = IdList();
Near = IdView();
}
AActorPtr FTangibleManager::GetTangible(int64 id) {
@@ -28,7 +28,6 @@ AActorPtr FTangibleManager::GetTangible(int64 id) {
}
}
// Get the tangible if it exists, otherwise create it.
AActorPtr FTangibleManager::MakeTangible(int64 id) {
AActorPtr& p = IdToActor.FindOrAdd(id);
if (p == nullptr) {
@@ -41,7 +40,16 @@ AActorPtr FTangibleManager::MakeTangible(int64 id) {
return p;
}
// Delete the tangible.
void FTangibleManager::DeleteTangible(int64 id) {
// IMPLEMENT ME
}
FTangibleManager::IdArray FTangibleManager::GetLive() {
IdArray result;
result.SetNum(IdToActor.Num());
int next = 0;
for (auto &pair : IdToActor) {
result[next++] = pair.Key;
}
return result;
}

View File

@@ -4,6 +4,7 @@
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "CommonTypes.h"
#include "TangibleManager.generated.h"
/**
@@ -14,9 +15,10 @@ struct INTEGRATION_API FTangibleManager
{
GENERATED_BODY()
public:
using IdList = TArrayView<const int64>;
// Import these types into our Namespace.
using IdArray = LuprexCommonTypes::IdArray;
using IdView = LuprexCommonTypes::IdView;
public:
// A pointer to the UWorld.
UWorld* World;
@@ -32,7 +34,7 @@ public:
int64 Actor;
// Tangibles near the actor.
IdList Near;
IdView Near;
public:
FTangibleManager();
@@ -55,9 +57,15 @@ public:
int64 GetActor() const { return Actor; };
void SetActor(int64 id) { Actor = id; }
// Get/Set the list of tangibles near the player.
// Get/Set the list of tangibles near the player, according to Luprex.
//
IdList GetNear() const { return Near; }
void SetNear(IdList near) { Near = near; }
IdView GetNear() const { return Near; }
void SetNear(IdView near) { Near = near; }
// Get the Live list.
//
// Efficiency note: this makes a copy of the array.
//
IdArray GetLive();
};