TangibleCharacter can now be interactively controlled
This commit is contained in:
@@ -71,3 +71,13 @@ ConnectionType=USBOnly
|
|||||||
bUseManualIPAddress=False
|
bUseManualIPAddress=False
|
||||||
ManualIPAddress=
|
ManualIPAddress=
|
||||||
|
|
||||||
|
[/Script/LinuxTargetPlatform.LinuxTargetSettings]
|
||||||
|
SpatializationPlugin=
|
||||||
|
SourceDataOverridePlugin=
|
||||||
|
ReverbPlugin=
|
||||||
|
OcclusionPlugin=
|
||||||
|
SoundCueCookQualityIndex=-1
|
||||||
|
-TargetedRHIs=SF_VULKAN_SM5
|
||||||
|
+TargetedRHIs=SF_VULKAN_SM5
|
||||||
|
+TargetedRHIs=SF_VULKAN_SM6
|
||||||
|
|
||||||
|
|||||||
BIN
Content/BP_GameMode.uasset
LFS
Normal file
BIN
Content/BP_GameMode.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/ConsoleBP.uasset
LFS
BIN
Content/ConsoleBP.uasset
LFS
Binary file not shown.
BIN
Content/GlobalFunctions.uasset
LFS
BIN
Content/GlobalFunctions.uasset
LFS
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Content/ThirdPerson/Blueprints/BP_DefaultPawn.uasset
LFS
Normal file
BIN
Content/ThirdPerson/Blueprints/BP_DefaultPawn.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset
LFS
Normal file
BIN
Content/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/ThirdPerson/Input/Actions/IA_Focus_Console.uasset
LFS
Normal file
BIN
Content/ThirdPerson/Input/Actions/IA_Focus_Console.uasset
LFS
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -17,6 +17,7 @@ using namespace CommonTypes;
|
|||||||
AIntegrationGameModeBase::AIntegrationGameModeBase()
|
AIntegrationGameModeBase::AIntegrationGameModeBase()
|
||||||
{
|
{
|
||||||
TangibleManager = NewObject<UlxTangibleManager>();
|
TangibleManager = NewObject<UlxTangibleManager>();
|
||||||
|
PlayerId = 0;
|
||||||
EngineSeconds = 0.0;
|
EngineSeconds = 0.0;
|
||||||
NextThreadTrigger = 1.0;
|
NextThreadTrigger = 1.0;
|
||||||
//PrimaryActorTick.bCanEverTick = true; // Probably wrong
|
//PrimaryActorTick.bCanEverTick = true; // Probably wrong
|
||||||
@@ -113,14 +114,13 @@ void AIntegrationGameModeBase::MaybeTriggerUpdateTask(float deltaseconds) {
|
|||||||
|
|
||||||
|
|
||||||
#pragma optimize("", off)
|
#pragma optimize("", off)
|
||||||
|
|
||||||
void AIntegrationGameModeBase::UpdateTangibles() {
|
void AIntegrationGameModeBase::UpdateTangibles() {
|
||||||
double radius = 1000.0; // Hardwired for now.
|
double radius = 1000.0; // Hardwired for now.
|
||||||
using TanArray = UlxTangibleManager::TanArray;
|
using TanArray = UlxTangibleManager::TanArray;
|
||||||
if (!Playing) return;
|
if (!Playing) return;
|
||||||
FlxLockedWrapper w(LockableWrapper);
|
FlxLockedWrapper w(LockableWrapper);
|
||||||
int64 player = w.GetActor();
|
PlayerId = w.GetActor();
|
||||||
IdView nearids = w.GetNear(player, radius, radius, radius);
|
IdView nearids = w.GetNear(PlayerId, radius, radius, radius);
|
||||||
TangibleManager->UpdateNearAccordingToLuprex(nearids);
|
TangibleManager->UpdateNearAccordingToLuprex(nearids);
|
||||||
TanArray alltans = TangibleManager->GetAllTangibles();
|
TanArray alltans = TangibleManager->GetAllTangibles();
|
||||||
IdArray allids = TangibleManager->GetIds(alltans);
|
IdArray allids = TangibleManager->GetIds(alltans);
|
||||||
@@ -128,7 +128,7 @@ void AIntegrationGameModeBase::UpdateTangibles() {
|
|||||||
for (int i = 0; i < alltans.Num(); i++) {
|
for (int i = 0; i < alltans.Num(); i++) {
|
||||||
alltans[i]->UpdateAnimationQueue(allqueues[i]);
|
alltans[i]->UpdateAnimationQueue(allqueues[i]);
|
||||||
}
|
}
|
||||||
TangibleManager->RecalcNearAccordingToUnreal(player, radius);
|
TangibleManager->RecalcNearAccordingToUnreal(PlayerId, radius);
|
||||||
TangibleManager->DeleteFarawayTangibles();
|
TangibleManager->DeleteFarawayTangibles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,6 +155,10 @@ void AIntegrationGameModeBase::ExecuteDebuggingCommand(const FString &fs) {
|
|||||||
|
|
||||||
void AIntegrationGameModeBase::ConsoleSendInput(const FString& fs)
|
void AIntegrationGameModeBase::ConsoleSendInput(const FString& fs)
|
||||||
{
|
{
|
||||||
|
if (fs.IsEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FlxLockedWrapper w(LockableWrapper);
|
FlxLockedWrapper w(LockableWrapper);
|
||||||
if (w->engine != nullptr)
|
if (w->engine != nullptr)
|
||||||
{
|
{
|
||||||
@@ -253,7 +257,7 @@ void AIntegrationGameModeBase::BeginPlay()
|
|||||||
|
|
||||||
// Initialize the tangible manager.
|
// Initialize the tangible manager.
|
||||||
TangibleManager = NewObject<UlxTangibleManager>();
|
TangibleManager = NewObject<UlxTangibleManager>();
|
||||||
TangibleManager->Init(GetWorld());
|
TangibleManager->Init(GetWorld(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||||
@@ -261,3 +265,6 @@ void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
|||||||
ResetToInitialState();
|
ResetToInitialState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64 AIntegrationGameModeBase::GetPlayerId() {
|
||||||
|
return PlayerId;
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "Luprex")
|
UFUNCTION(BlueprintCallable, Category = "Luprex")
|
||||||
void ConsoleSendInput(const FString& text);
|
void ConsoleSendInput(const FString& text);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Luprex")
|
||||||
|
int64 GetPlayerId();
|
||||||
|
|
||||||
// Execute a debugging command, typed on the GUI.
|
// Execute a debugging command, typed on the GUI.
|
||||||
void ExecuteDebuggingCommand(const FString &fs);
|
void ExecuteDebuggingCommand(const FString &fs);
|
||||||
|
|
||||||
@@ -72,9 +75,11 @@ public:
|
|||||||
TUniquePtr<FlxSockets> Sockets;
|
TUniquePtr<FlxSockets> Sockets;
|
||||||
|
|
||||||
// True if 'BeginPlay' has been successfully completed.
|
// True if 'BeginPlay' has been successfully completed.
|
||||||
//
|
|
||||||
bool Playing;
|
bool Playing;
|
||||||
|
|
||||||
|
// Current Player ID
|
||||||
|
int64 PlayerId;
|
||||||
|
|
||||||
// Amount of elapsed time since BeginPlay.
|
// Amount of elapsed time since BeginPlay.
|
||||||
float EngineSeconds;
|
float EngineSeconds;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "Tangible.h"
|
#include "Tangible.h"
|
||||||
#include "TangibleManager.h"
|
#include "TangibleManager.h"
|
||||||
|
#include "IntegrationGameModeBase.h"
|
||||||
|
|
||||||
#define DEFAULT_BLUEPRINT (TEXT("TangibleStaticMesh"))
|
#define DEFAULT_BLUEPRINT (TEXT("TangibleStaticMesh"))
|
||||||
|
|
||||||
@@ -59,23 +60,37 @@ void UlxTangible::SetActorBlueprint(const FString &name) {
|
|||||||
|
|
||||||
// Now create a new actor, unless the BP is nullptr.
|
// Now create a new actor, unless the BP is nullptr.
|
||||||
if (blueprint != nullptr) {
|
if (blueprint != nullptr) {
|
||||||
// Create the actor.
|
|
||||||
FActorSpawnParameters params;
|
|
||||||
FVector location(0, 0, 0);
|
|
||||||
FRotator rotation(0, 0, 0);
|
|
||||||
UWorld* w = Manager->GetWorld();
|
UWorld* w = Manager->GetWorld();
|
||||||
|
FActorSpawnParameters params;
|
||||||
|
|
||||||
|
// Currently, the actor is spawned at (0,0,0), which is not good.
|
||||||
|
// We should spawn at the actor's current location. I'll get to it
|
||||||
|
// eventually.
|
||||||
|
FTransform transform;
|
||||||
|
transform.SetLocation(FVector(0,0,0));
|
||||||
|
transform.SetRotation(FQuat(FRotator(0,0,0)));
|
||||||
|
|
||||||
|
// Create the actor at the specified location even if there's something in the way.
|
||||||
params.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
params.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||||
AActor* a = w->SpawnActor(blueprint, &location, &rotation, params);
|
|
||||||
|
// Normally, SpawnActor runs the BeginPlay entry point. We
|
||||||
|
// want to delay that until after we've had a chance to set
|
||||||
|
// up the TangibleComponent.
|
||||||
|
params.bDeferConstruction = true;
|
||||||
|
AActor* a = w->SpawnActor(blueprint, &transform, params);
|
||||||
check(a != nullptr);
|
check(a != nullptr);
|
||||||
|
|
||||||
// Insert a TangibleComponent into the actor.
|
// Insert a TangibleComponent into the actor.
|
||||||
|
// Link the actor to its tangible, and the tangible to its actor.
|
||||||
UActorComponent* ac = a->AddComponentByClass(UlxTangibleComponent::StaticClass(), false, FTransform::Identity, false);
|
UActorComponent* ac = a->AddComponentByClass(UlxTangibleComponent::StaticClass(), false, FTransform::Identity, false);
|
||||||
UlxTangibleComponent* tc = Cast<UlxTangibleComponent>(ac);
|
UlxTangibleComponent* tc = Cast<UlxTangibleComponent>(ac);
|
||||||
check(tc != nullptr);
|
check(tc != nullptr);
|
||||||
|
|
||||||
// Make the tangible point to the actor and vice versa.
|
|
||||||
tc->Tangible = this;
|
tc->Tangible = this;
|
||||||
CurrentActor = a;
|
CurrentActor = a;
|
||||||
|
|
||||||
|
// This executes the BeginPlay entry point. We have to do this here
|
||||||
|
// because we deferred it in SpawnActor.
|
||||||
|
a->FinishSpawning(transform, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,3 +155,8 @@ void UlxTangible::SetTangiblePlane(AActor* target, const FString& plane) {
|
|||||||
GetActorTangible(target)->Plane = FName(plane);
|
GetActorTangible(target)->Plane = FName(plane);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UlxTangible::IsCurrentPlayer(AActor* target) {
|
||||||
|
UlxTangible *tan = GetActorTangible(target);
|
||||||
|
AIntegrationGameModeBase *gamemode = tan->Manager->GetGameMode();
|
||||||
|
return (tan->TangibleId == gamemode->PlayerId);
|
||||||
|
}
|
||||||
@@ -160,6 +160,9 @@ public:
|
|||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex)
|
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex)
|
||||||
static void SetTangiblePlane(AActor* target, const FString& plane);
|
static void SetTangiblePlane(AActor* target, const FString& plane);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex)
|
||||||
|
static bool IsCurrentPlayer(AActor *target);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "TangibleManager.h"
|
#include "TangibleManager.h"
|
||||||
#include "Tangible.h"
|
#include "Tangible.h"
|
||||||
#include "DebugPrint.h"
|
#include "DebugPrint.h"
|
||||||
|
#include "IntegrationGameModeBase.h"
|
||||||
|
|
||||||
using namespace DebugPrint;
|
using namespace DebugPrint;
|
||||||
using TanArray = UlxTangibleManager::TanArray;
|
using TanArray = UlxTangibleManager::TanArray;
|
||||||
@@ -36,8 +37,9 @@ UlxTangibleManager::UlxTangibleManager() {
|
|||||||
World = nullptr;
|
World = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UlxTangibleManager::Init(UWorld* world) {
|
void UlxTangibleManager::Init(UWorld* world, AIntegrationGameModeBase *gamemode) {
|
||||||
World = world;
|
World = world;
|
||||||
|
GameMode = gamemode;
|
||||||
}
|
}
|
||||||
|
|
||||||
UlxTangible* UlxTangibleManager::GetTangible(int64 id) const {
|
UlxTangible* UlxTangibleManager::GetTangible(int64 id) const {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include "Tangible.h"
|
#include "Tangible.h"
|
||||||
#include "TangibleManager.generated.h"
|
#include "TangibleManager.generated.h"
|
||||||
|
|
||||||
|
class AIntegrationGameModeBase;
|
||||||
|
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class INTEGRATION_API UlxTangibleManager : public UObject
|
class INTEGRATION_API UlxTangibleManager : public UObject
|
||||||
{
|
{
|
||||||
@@ -23,6 +25,10 @@ public:
|
|||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TWeakObjectPtr<UWorld> World;
|
TWeakObjectPtr<UWorld> World;
|
||||||
|
|
||||||
|
// A pointer to our game mode.
|
||||||
|
UPROPERTY()
|
||||||
|
TWeakObjectPtr<AIntegrationGameModeBase> GameMode;
|
||||||
|
|
||||||
// Given a tangible ID, look up the TangibleComponent of that actor.
|
// Given a tangible ID, look up the TangibleComponent of that actor.
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TMap<int64, UlxTangible*> IdToTangible;
|
TMap<int64, UlxTangible*> IdToTangible;
|
||||||
@@ -32,12 +38,15 @@ public:
|
|||||||
|
|
||||||
// Initialize the tangible manager.
|
// Initialize the tangible manager.
|
||||||
//
|
//
|
||||||
void Init(UWorld *world);
|
void Init(UWorld *world, AIntegrationGameModeBase *gamemode);
|
||||||
|
|
||||||
// Get a pointer to our world.
|
// Get a pointer to our world.
|
||||||
//
|
//
|
||||||
UWorld* GetWorld() const override { return World.Get(); }
|
UWorld* GetWorld() const override { return World.Get(); }
|
||||||
|
|
||||||
|
// Get a pointer to our game mode.
|
||||||
|
AIntegrationGameModeBase *GetGameMode() { return GameMode.Get(); }
|
||||||
|
|
||||||
// Get the tangible if it exists, otherwise return NULL
|
// Get the tangible if it exists, otherwise return NULL
|
||||||
//
|
//
|
||||||
UlxTangible* GetTangible(int64 id) const;
|
UlxTangible* GetTangible(int64 id) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user