diff --git a/Source/Integration/AnimQueue.cpp b/Source/Integration/AnimQueue.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Source/Integration/AnimQueue.h b/Source/Integration/AnimQueue.h new file mode 100644 index 00000000..e69de29b diff --git a/Source/Integration/CommonTypes.h b/Source/Integration/CommonTypes.h new file mode 100644 index 00000000..2c7243a5 --- /dev/null +++ b/Source/Integration/CommonTypes.h @@ -0,0 +1,9 @@ +#pragma once + +namespace LuprexCommonTypes { + // Array of tangible IDs. + using IdArray = TArray; + + // View of Array of tangible IDs. + using IdView = TArrayView; +} \ No newline at end of file diff --git a/Source/Integration/LockedWrapper.cpp b/Source/Integration/LockedWrapper.cpp index 28db6c87..793562d9 100644 --- a/Source/Integration/LockedWrapper.cpp +++ b/Source/Integration/LockedWrapper.cpp @@ -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); } diff --git a/Source/Integration/LockedWrapper.h b/Source/Integration/LockedWrapper.h index c8db921a..e3762234 100644 --- a/Source/Integration/LockedWrapper.h +++ b/Source/Integration/LockedWrapper.h @@ -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; +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); }; diff --git a/Source/Integration/TangibleManager.cpp b/Source/Integration/TangibleManager.cpp index 333f8962..e041c935 100644 --- a/Source/Integration/TangibleManager.cpp +++ b/Source/Integration/TangibleManager.cpp @@ -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; +} \ No newline at end of file diff --git a/Source/Integration/TangibleManager.h b/Source/Integration/TangibleManager.h index 4d89ad63..430db3d9 100644 --- a/Source/Integration/TangibleManager.h +++ b/Source/Integration/TangibleManager.h @@ -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; + // 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(); };