Move tangible state into TangibleComponent

This commit is contained in:
2023-09-25 18:00:34 -04:00
parent 2f5baf2e9f
commit 254524aab6
11 changed files with 211 additions and 72 deletions

View File

@@ -5,7 +5,7 @@
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "CommonTypes.h"
#include "Tangible.h"
#include "TangibleComponent.h"
#include "TangibleManager.generated.h"
UCLASS()
@@ -18,19 +18,21 @@ public:
using IdArray = CommonTypes::IdArray;
using IdView = CommonTypes::IdView;
// A pointer to the UWorld.
UWorld* World;
// A pointer to our world.
UPROPERTY()
TWeakObjectPtr<UWorld> World;
// A pointer to uclass TangibleActor.
// A pointer to uclass TangibleActor. This is the class
// of actors that we create (for now).
UPROPERTY()
TSubclassOf<AActor> ClassTangibleActor;
// Given a tangible ID, look up actor pointer (or NULL if actor was deleted)
UPROPERTY()
TMap<int64, UlxTangible*> IdToTangible;
TMap<int64, AActor*> IdToActor;
// Actor tangible Id.
int64 Actor;
// Player's tangible Id.
int64 Player;
// Tangibles near the actor.
IdView Near;
@@ -42,19 +44,23 @@ public:
//
void Init(UWorld *world, UClass* tanact);
// Get a pointer to our world.
//
UWorld* GetWorld() const override { return World.Get(); }
// Get the tangible if it exists, otherwise return NULL
UlxTangible* GetTangible(int64 id);
UTangibleComponent* GetTangible(int64 id);
// Get the tangible if it exists, otherwise create it.
UlxTangible* MakeTangible(int64 id);
UTangibleComponent* MakeTangible(int64 id);
// Delete the tangible.
void DeleteTangible(int64 id);
// Get/Set the Id of the actor.
//
int64 GetActor() const { return Actor; };
void SetActor(int64 id) { Actor = id; }
int64 GetPlayer() const { return Player; };
void SetPlayer(int64 id) { Player = id; }
// Get/Set the list of tangibles near the player, according to Luprex.
//