Make TangibleManager a UObject

This commit is contained in:
2023-09-25 14:25:24 -04:00
parent 982b6cab62
commit 2f5baf2e9f
8 changed files with 33 additions and 28 deletions

Binary file not shown.

View File

@@ -42,7 +42,7 @@ static bool SetProperty(const FString& name, UObject* obj, const FlxAnimationFie
FDoubleProperty* fprop = FindFProperty<FDoubleProperty>(uclass, nname); FDoubleProperty* fprop = FindFProperty<FDoubleProperty>(uclass, nname);
if (fprop == nullptr) return false; if (fprop == nullptr) return false;
double* pptr = fprop->ContainerPtrToValuePtr<double>(obj); double* pptr = fprop->ContainerPtrToValuePtr<double>(obj);
fprop->SetPropertyValue(pptr, field.X); *pptr = field.X;
return true; return true;
} }
case ElxAnimValueType::BOOLEAN: { case ElxAnimValueType::BOOLEAN: {

View File

@@ -129,18 +129,13 @@ public:
UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex) UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex)
static bool AnimationStepGetBool(const FlxAnimationStep& step, const FString& name); static bool AnimationStepGetBool(const FlxAnimationStep& step, const FString& name);
}; };
//////////////////////////////////////////////// ////////////////////////////////////////////////
// //
// Exposing functions to blueprints.
// //
//////////////////////////////////////////////// ////////////////////////////////////////////////
//UFUNCTION(BlueprintCallable)
//void Unpack(const FString& prefix, UObject* into, bool preclear = true);
struct FlxAnimationStepView { struct FlxAnimationStepView {
uint64 Hash; uint64 Hash;
std::string_view Body; std::string_view Body;

View File

@@ -16,6 +16,7 @@ using namespace CommonTypes;
AIntegrationGameModeBase::AIntegrationGameModeBase() AIntegrationGameModeBase::AIntegrationGameModeBase()
{ {
TangibleManager = NewObject<UTangibleManager>();
EngineSeconds = 0.0; EngineSeconds = 0.0;
NextThreadTrigger = 1.0; NextThreadTrigger = 1.0;
//PrimaryActorTick.bCanEverTick = true; // Probably wrong //PrimaryActorTick.bCanEverTick = true; // Probably wrong
@@ -47,6 +48,11 @@ void AIntegrationGameModeBase::ResetToInitialState()
{ {
Playing = false; Playing = false;
if (TangibleManager != nullptr) {
TangibleManager->ConditionalBeginDestroy();
TangibleManager = nullptr;
}
// Shut down the thread // Shut down the thread
LuprexUpdateTask.Shutdown(); LuprexUpdateTask.Shutdown();
@@ -117,18 +123,18 @@ void AIntegrationGameModeBase::UpdateTangibles() {
if (!Playing) return; if (!Playing) return;
FlxLockedWrapper w(LockableWrapper); FlxLockedWrapper w(LockableWrapper);
int64 actor = w.GetActor(); int64 actor = w.GetActor();
TangibleManager.SetActor(actor); TangibleManager->SetActor(actor);
TangibleManager.SetNear(w.GetNear(actor, 100, 100, 100)); TangibleManager->SetNear(w.GetNear(actor, 100, 100, 100));
for (int64 id : TangibleManager.GetNear()) { for (int64 id : TangibleManager->GetNear()) {
TangibleManager.MakeTangible(id); TangibleManager->MakeTangible(id);
} }
// Update animation queues of live tangibles. // Update animation queues of live tangibles.
IdArray tanids = TangibleManager.GetLive(); IdArray tanids = TangibleManager->GetLive();
StringViewVec aqueues = w.GetAnimationQueues(tanids); StringViewVec aqueues = w.GetAnimationQueues(tanids);
for (int i = 0; i < tanids.Num(); i++) { for (int i = 0; i < tanids.Num(); i++) {
uint64_t tanid = tanids[i]; uint64_t tanid = tanids[i];
std::string_view aqueue = aqueues[i]; std::string_view aqueue = aqueues[i];
UlxTangible* t = TangibleManager.GetTangible(tanid); UlxTangible* t = TangibleManager->GetTangible(tanid);
check(t != nullptr); check(t != nullptr);
t->AnimTracker.Update(aqueue); t->AnimTracker.Update(aqueue);
@@ -237,7 +243,8 @@ void AIntegrationGameModeBase::BeginPlay()
} }
// Initialize the tangible manager. // Initialize the tangible manager.
TangibleManager.Init(GetWorld(), ClassTangibleActor); TangibleManager = NewObject<UTangibleManager>();
TangibleManager->Init(GetWorld(), ClassTangibleActor);
} }
void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason) void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason)

View File

@@ -57,7 +57,7 @@ public:
virtual uint32 Run() override; virtual uint32 Run() override;
UPROPERTY() UPROPERTY()
FTangibleManager TangibleManager; UTangibleManager *TangibleManager;
// This stores the entire text currently visible in the console. // This stores the entire text currently visible in the console.
FlxConsoleOutput ConsoleOutput; FlxConsoleOutput ConsoleOutput;

View File

@@ -22,8 +22,10 @@ public:
FlxAnimTracker AnimTracker; FlxAnimTracker AnimTracker;
void Init(AActor* a) { FString Plane;
void Init(AActor* a, const FString &plane) {
Actor = a; Actor = a;
Plane = plane;
} }
}; };

View File

@@ -7,21 +7,21 @@
using namespace DebugPrint; using namespace DebugPrint;
FTangibleManager::FTangibleManager() { UTangibleManager::UTangibleManager() {
World = nullptr; World = nullptr;
ClassTangibleActor = nullptr; ClassTangibleActor = nullptr;
Actor = 0; Actor = 0;
Near = IdView(); Near = IdView();
} }
void FTangibleManager::Init(UWorld *world, UClass* tanact) { void UTangibleManager::Init(UWorld *world, UClass* tanact) {
World = world; World = world;
ClassTangibleActor = tanact; ClassTangibleActor = tanact;
Actor = 0; Actor = 0;
Near = IdView(); Near = IdView();
} }
UlxTangible *FTangibleManager::GetTangible(int64 id) { UlxTangible *UTangibleManager::GetTangible(int64 id) {
UlxTangible **p = IdToTangible.Find(id); UlxTangible **p = IdToTangible.Find(id);
if (p == nullptr) { if (p == nullptr) {
return nullptr; return nullptr;
@@ -30,7 +30,7 @@ UlxTangible *FTangibleManager::GetTangible(int64 id) {
} }
} }
UlxTangible *FTangibleManager::MakeTangible(int64 id) { UlxTangible *UTangibleManager::MakeTangible(int64 id) {
UlxTangible *& p = IdToTangible.FindOrAdd(id); UlxTangible *& p = IdToTangible.FindOrAdd(id);
if (p == nullptr) { if (p == nullptr) {
FVector location(0,0,0); FVector location(0,0,0);
@@ -40,16 +40,16 @@ UlxTangible *FTangibleManager::MakeTangible(int64 id) {
check(a != nullptr); check(a != nullptr);
check(a->GetClass()->ImplementsInterface(UlxTangibleInterface::StaticClass())); check(a->GetClass()->ImplementsInterface(UlxTangibleInterface::StaticClass()));
p = NewObject<UlxTangible>(); p = NewObject<UlxTangible>();
p->Init(a); p->Init(a, TEXT(""));
} }
return p; return p;
} }
void FTangibleManager::DeleteTangible(int64 id) { void UTangibleManager::DeleteTangible(int64 id) {
// IMPLEMENT ME // IMPLEMENT ME
} }
FTangibleManager::IdArray FTangibleManager::GetLive() { UTangibleManager::IdArray UTangibleManager::GetLive() {
IdArray result; IdArray result;
result.SetNum(IdToTangible.Num()); result.SetNum(IdToTangible.Num());
int next = 0; int next = 0;

View File

@@ -8,10 +8,11 @@
#include "Tangible.h" #include "Tangible.h"
#include "TangibleManager.generated.h" #include "TangibleManager.generated.h"
USTRUCT() UCLASS()
struct INTEGRATION_API FTangibleManager class INTEGRATION_API UTangibleManager : public UObject
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
// Import these types into our Namespace. // Import these types into our Namespace.
using IdArray = CommonTypes::IdArray; using IdArray = CommonTypes::IdArray;
@@ -35,7 +36,7 @@ public:
IdView Near; IdView Near;
public: public:
FTangibleManager(); UTangibleManager();
// Initialize the tangible manager. // Initialize the tangible manager.
// //