From d11fbca8156fb693d71733fbd6c8b634425633d2 Mon Sep 17 00:00:00 2001 From: jyelon Date: Fri, 2 Feb 2024 15:48:27 -0500 Subject: [PATCH] TangibleCharacter can now be interactively controlled --- Config/DefaultEngine.ini | 10 ++++++ Content/BP_GameMode.uasset | 3 ++ Content/ConsoleBP.uasset | 4 +-- Content/GlobalFunctions.uasset | 4 +-- Content/IntegrationGameModeBaseBP.uasset | 4 +-- Content/Tangibles/TangibleCharacter.uasset | 4 +-- .../Blueprints/BP_Controller.uasset | 4 +-- .../Blueprints/BP_DefaultPawn.uasset | 3 ++ .../Blueprints/BP_ThirdPersonCharacter.uasset | 3 ++ .../Input/Actions/IA_Focus_Console.uasset | 3 ++ .../ThirdPerson/Input/Actions/IA_Move.uasset | 2 +- Content/ThirdPerson/Input/IMC_Default.uasset | 4 +-- .../Integration/IntegrationGameModeBase.cpp | 17 +++++++--- Source/Integration/IntegrationGameModeBase.h | 7 +++- Source/Integration/Tangible.cpp | 34 +++++++++++++++---- Source/Integration/Tangible.h | 3 ++ Source/Integration/TangibleManager.cpp | 4 ++- Source/Integration/TangibleManager.h | 11 +++++- 18 files changed, 96 insertions(+), 28 deletions(-) create mode 100644 Content/BP_GameMode.uasset create mode 100644 Content/ThirdPerson/Blueprints/BP_DefaultPawn.uasset create mode 100644 Content/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset create mode 100644 Content/ThirdPerson/Input/Actions/IA_Focus_Console.uasset diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index ef3c9672..d63a1041 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -71,3 +71,13 @@ ConnectionType=USBOnly bUseManualIPAddress=False ManualIPAddress= +[/Script/LinuxTargetPlatform.LinuxTargetSettings] +SpatializationPlugin= +SourceDataOverridePlugin= +ReverbPlugin= +OcclusionPlugin= +SoundCueCookQualityIndex=-1 +-TargetedRHIs=SF_VULKAN_SM5 ++TargetedRHIs=SF_VULKAN_SM5 ++TargetedRHIs=SF_VULKAN_SM6 + diff --git a/Content/BP_GameMode.uasset b/Content/BP_GameMode.uasset new file mode 100644 index 00000000..9e111223 --- /dev/null +++ b/Content/BP_GameMode.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:00d518464edc721eedfa910044b337768d036529d699b5107928f74869d73c71 +size 59331 diff --git a/Content/ConsoleBP.uasset b/Content/ConsoleBP.uasset index bbba3de0..1bfa8e95 100644 --- a/Content/ConsoleBP.uasset +++ b/Content/ConsoleBP.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9d2649bd20de3fb82288cdd4d0b01f4767b35758348c675d4475732c5b7a7a75 -size 68511 +oid sha256:44894a71555443b2e286d11e1b096f3b51229a1691747a294a449e9f16348899 +size 69985 diff --git a/Content/GlobalFunctions.uasset b/Content/GlobalFunctions.uasset index e966c14b..b4ccf5f9 100644 --- a/Content/GlobalFunctions.uasset +++ b/Content/GlobalFunctions.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f880c4e7c1db7db581a583553d384a5c7cbc2930f1c30d6643c3b81b63e2908e -size 26160 +oid sha256:860036a98427efe7a115df2c32fb2bf2bee3c7b0639141156d560c6700b45ef4 +size 27679 diff --git a/Content/IntegrationGameModeBaseBP.uasset b/Content/IntegrationGameModeBaseBP.uasset index aa473885..85c09796 100644 --- a/Content/IntegrationGameModeBaseBP.uasset +++ b/Content/IntegrationGameModeBaseBP.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:43718d556a2a71f7aaa29c3bc93edce6a2de4bdaf35e09a1430f25b01069d2ea -size 54726 +oid sha256:051dd5b3dd862575e93db8cffbd0ce3ba1833ca7ab1e3ec0d5a05ba618dc3531 +size 2431 diff --git a/Content/Tangibles/TangibleCharacter.uasset b/Content/Tangibles/TangibleCharacter.uasset index 67002bdd..1ad5223e 100644 --- a/Content/Tangibles/TangibleCharacter.uasset +++ b/Content/Tangibles/TangibleCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:874dc397db0451cbb899cc96539064a91a2a00eefefe93064cca668ca9d01c96 -size 460174 +oid sha256:bef016f4e5e11071d5279b7ef36fb40a5fba609573a884b1232916fc7afe12e2 +size 491301 diff --git a/Content/ThirdPerson/Blueprints/BP_Controller.uasset b/Content/ThirdPerson/Blueprints/BP_Controller.uasset index 83de936c..e484b522 100644 --- a/Content/ThirdPerson/Blueprints/BP_Controller.uasset +++ b/Content/ThirdPerson/Blueprints/BP_Controller.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:273b5408f258e86262b83ff7161296f71b06a89326810ddd887139e9bf499090 -size 15174 +oid sha256:13285b293ed172e320fdc3be291af09f700e92b2016d4001e3c6ade36bd85d18 +size 13266 diff --git a/Content/ThirdPerson/Blueprints/BP_DefaultPawn.uasset b/Content/ThirdPerson/Blueprints/BP_DefaultPawn.uasset new file mode 100644 index 00000000..557070ad --- /dev/null +++ b/Content/ThirdPerson/Blueprints/BP_DefaultPawn.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d68823c08d284a4a810a5a4c1a274c3a4ca4d9bdd846d174030c8d0a3ca41525 +size 66883 diff --git a/Content/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset b/Content/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset new file mode 100644 index 00000000..9d70104a --- /dev/null +++ b/Content/ThirdPerson/Blueprints/BP_ThirdPersonCharacter.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7cc417e7a614c311831f25c832f0fda957bd63a5d1b471f78040831a8583bab6 +size 126119 diff --git a/Content/ThirdPerson/Input/Actions/IA_Focus_Console.uasset b/Content/ThirdPerson/Input/Actions/IA_Focus_Console.uasset new file mode 100644 index 00000000..4a32143b --- /dev/null +++ b/Content/ThirdPerson/Input/Actions/IA_Focus_Console.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18a3febd9200988f16260d44a58e3a24f1353c40174ad1fb107fbb46c3471053 +size 1363 diff --git a/Content/ThirdPerson/Input/Actions/IA_Move.uasset b/Content/ThirdPerson/Input/Actions/IA_Move.uasset index ed0fb620..46580aa9 100644 --- a/Content/ThirdPerson/Input/Actions/IA_Move.uasset +++ b/Content/ThirdPerson/Input/Actions/IA_Move.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:70d10a9c1feba83f2612b7e603967451cba0ed16493965baa4e99cfee54d841d +oid sha256:683d07bfbf08c73ad79093e21aaae9b519c6e535e7cf280222612abb2fd7631f size 1465 diff --git a/Content/ThirdPerson/Input/IMC_Default.uasset b/Content/ThirdPerson/Input/IMC_Default.uasset index cac8cf2c..27b83048 100644 --- a/Content/ThirdPerson/Input/IMC_Default.uasset +++ b/Content/ThirdPerson/Input/IMC_Default.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f6665b9140e0038c31fd900101d5a5a37fc42cc8dd5427be9968bbcd04d400bf -size 13933 +oid sha256:912170b61ab2c644d45db76c87b54ecaf82d9efbec4a097b2e0e277d3e2cc4b9 +size 14533 diff --git a/Source/Integration/IntegrationGameModeBase.cpp b/Source/Integration/IntegrationGameModeBase.cpp index aba67aa8..0ce0af61 100644 --- a/Source/Integration/IntegrationGameModeBase.cpp +++ b/Source/Integration/IntegrationGameModeBase.cpp @@ -17,6 +17,7 @@ using namespace CommonTypes; AIntegrationGameModeBase::AIntegrationGameModeBase() { TangibleManager = NewObject(); + PlayerId = 0; EngineSeconds = 0.0; NextThreadTrigger = 1.0; //PrimaryActorTick.bCanEverTick = true; // Probably wrong @@ -113,14 +114,13 @@ void AIntegrationGameModeBase::MaybeTriggerUpdateTask(float deltaseconds) { #pragma optimize("", off) - void AIntegrationGameModeBase::UpdateTangibles() { double radius = 1000.0; // Hardwired for now. using TanArray = UlxTangibleManager::TanArray; if (!Playing) return; FlxLockedWrapper w(LockableWrapper); - int64 player = w.GetActor(); - IdView nearids = w.GetNear(player, radius, radius, radius); + PlayerId = w.GetActor(); + IdView nearids = w.GetNear(PlayerId, radius, radius, radius); TangibleManager->UpdateNearAccordingToLuprex(nearids); TanArray alltans = TangibleManager->GetAllTangibles(); IdArray allids = TangibleManager->GetIds(alltans); @@ -128,7 +128,7 @@ void AIntegrationGameModeBase::UpdateTangibles() { for (int i = 0; i < alltans.Num(); i++) { alltans[i]->UpdateAnimationQueue(allqueues[i]); } - TangibleManager->RecalcNearAccordingToUnreal(player, radius); + TangibleManager->RecalcNearAccordingToUnreal(PlayerId, radius); TangibleManager->DeleteFarawayTangibles(); } @@ -155,6 +155,10 @@ void AIntegrationGameModeBase::ExecuteDebuggingCommand(const FString &fs) { void AIntegrationGameModeBase::ConsoleSendInput(const FString& fs) { + if (fs.IsEmpty()) { + return; + } + FlxLockedWrapper w(LockableWrapper); if (w->engine != nullptr) { @@ -253,7 +257,7 @@ void AIntegrationGameModeBase::BeginPlay() // Initialize the tangible manager. TangibleManager = NewObject(); - TangibleManager->Init(GetWorld()); + TangibleManager->Init(GetWorld(), this); } void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason) @@ -261,3 +265,6 @@ void AIntegrationGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason) ResetToInitialState(); } +int64 AIntegrationGameModeBase::GetPlayerId() { + return PlayerId; +} diff --git a/Source/Integration/IntegrationGameModeBase.h b/Source/Integration/IntegrationGameModeBase.h index fc2b8bc2..cb5b3643 100644 --- a/Source/Integration/IntegrationGameModeBase.h +++ b/Source/Integration/IntegrationGameModeBase.h @@ -39,6 +39,9 @@ public: UFUNCTION(BlueprintCallable, Category = "Luprex") void ConsoleSendInput(const FString& text); + UFUNCTION(BlueprintCallable, Category = "Luprex") + int64 GetPlayerId(); + // Execute a debugging command, typed on the GUI. void ExecuteDebuggingCommand(const FString &fs); @@ -72,9 +75,11 @@ public: TUniquePtr Sockets; // True if 'BeginPlay' has been successfully completed. - // bool Playing; + // Current Player ID + int64 PlayerId; + // Amount of elapsed time since BeginPlay. float EngineSeconds; diff --git a/Source/Integration/Tangible.cpp b/Source/Integration/Tangible.cpp index 100f19aa..73bd6e27 100644 --- a/Source/Integration/Tangible.cpp +++ b/Source/Integration/Tangible.cpp @@ -3,6 +3,7 @@ #include "Tangible.h" #include "TangibleManager.h" +#include "IntegrationGameModeBase.h" #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. if (blueprint != nullptr) { - // Create the actor. - FActorSpawnParameters params; - FVector location(0, 0, 0); - FRotator rotation(0, 0, 0); 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; - 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); // 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); UlxTangibleComponent* tc = Cast(ac); check(tc != nullptr); - - // Make the tangible point to the actor and vice versa. tc->Tangible = this; 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); } +bool UlxTangible::IsCurrentPlayer(AActor* target) { + UlxTangible *tan = GetActorTangible(target); + AIntegrationGameModeBase *gamemode = tan->Manager->GetGameMode(); + return (tan->TangibleId == gamemode->PlayerId); +} \ No newline at end of file diff --git a/Source/Integration/Tangible.h b/Source/Integration/Tangible.h index 50e372b9..09c96dab 100644 --- a/Source/Integration/Tangible.h +++ b/Source/Integration/Tangible.h @@ -160,6 +160,9 @@ public: UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex) static void SetTangiblePlane(AActor* target, const FString& plane); + + UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "target"), Category = Luprex) + static bool IsCurrentPlayer(AActor *target); }; diff --git a/Source/Integration/TangibleManager.cpp b/Source/Integration/TangibleManager.cpp index 8e21d986..9649084f 100644 --- a/Source/Integration/TangibleManager.cpp +++ b/Source/Integration/TangibleManager.cpp @@ -4,6 +4,7 @@ #include "TangibleManager.h" #include "Tangible.h" #include "DebugPrint.h" +#include "IntegrationGameModeBase.h" using namespace DebugPrint; using TanArray = UlxTangibleManager::TanArray; @@ -36,8 +37,9 @@ UlxTangibleManager::UlxTangibleManager() { World = nullptr; } -void UlxTangibleManager::Init(UWorld* world) { +void UlxTangibleManager::Init(UWorld* world, AIntegrationGameModeBase *gamemode) { World = world; + GameMode = gamemode; } UlxTangible* UlxTangibleManager::GetTangible(int64 id) const { diff --git a/Source/Integration/TangibleManager.h b/Source/Integration/TangibleManager.h index 7f94de6e..4711d982 100644 --- a/Source/Integration/TangibleManager.h +++ b/Source/Integration/TangibleManager.h @@ -8,6 +8,8 @@ #include "Tangible.h" #include "TangibleManager.generated.h" +class AIntegrationGameModeBase; + UCLASS() class INTEGRATION_API UlxTangibleManager : public UObject { @@ -23,6 +25,10 @@ public: UPROPERTY() TWeakObjectPtr World; + // A pointer to our game mode. + UPROPERTY() + TWeakObjectPtr GameMode; + // Given a tangible ID, look up the TangibleComponent of that actor. UPROPERTY() TMap IdToTangible; @@ -32,12 +38,15 @@ public: // Initialize the tangible manager. // - void Init(UWorld *world); + void Init(UWorld *world, AIntegrationGameModeBase *gamemode); // Get a pointer to our world. // 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 // UlxTangible* GetTangible(int64 id) const;