diff --git a/Content/BP_GameMode.uasset b/Content/BP_GameMode.uasset deleted file mode 100644 index 9e111223..00000000 --- a/Content/BP_GameMode.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:00d518464edc721eedfa910044b337768d036529d699b5107928f74869d73c71 -size 59331 diff --git a/Content/GlobalFunctions.uasset b/Content/GlobalFunctions.uasset deleted file mode 100644 index b4ccf5f9..00000000 --- a/Content/GlobalFunctions.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:860036a98427efe7a115df2c32fb2bf2bee3c7b0639141156d560c6700b45ef4 -size 27679 diff --git a/Content/IntegrationGameModeBaseBP.uasset b/Content/IntegrationGameModeBaseBP.uasset index 85c09796..907be728 100644 --- a/Content/IntegrationGameModeBaseBP.uasset +++ b/Content/IntegrationGameModeBaseBP.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:051dd5b3dd862575e93db8cffbd0ce3ba1833ca7ab1e3ec0d5a05ba618dc3531 -size 2431 +oid sha256:04ce2437b374bfa84381b984c81495386e4f97e63fb0b72e084296d3daa7bc27 +size 2466 diff --git a/Content/Luprex/lxGameMode.uasset b/Content/Luprex/lxGameMode.uasset new file mode 100644 index 00000000..addf74aa --- /dev/null +++ b/Content/Luprex/lxGameMode.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53edabed12e415f9e9502194a05eae638fa83cde50b9078c532e8a475e21f365 +size 92330 diff --git a/Content/Luprex/lxLookAtDetectionLibrary.uasset b/Content/Luprex/lxLookAtDetectionLibrary.uasset new file mode 100644 index 00000000..38b68e07 --- /dev/null +++ b/Content/Luprex/lxLookAtDetectionLibrary.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a65cbfd4c1963480f8133f9cae8d0c322498aad2cab2d6de4adfd9aefe3f67b +size 78667 diff --git a/Content/Luprex/lxUtilityFunctionsLibrary.uasset b/Content/Luprex/lxUtilityFunctionsLibrary.uasset new file mode 100644 index 00000000..a985c4cd --- /dev/null +++ b/Content/Luprex/lxUtilityFunctionsLibrary.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8386ed92aea1cfc4da7cac923e1f8f4a60c8fd8813d4b3f100d3c5878a017b32 +size 27353 diff --git a/Content/Tangibles/TangibleCharacter.uasset b/Content/Tangibles/TangibleCharacter.uasset index 1174747c..0189c725 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:f0d9047abca327dcc1285cf8223a69c40c563be4f9c917516b5352e34fb8d63d -size 475102 +oid sha256:e6c82599641f056288f87232e73a7f267a5002999216fa030c6319f7a151cbf2 +size 474888 diff --git a/Content/Tangibles/TangibleStaticMesh.uasset b/Content/Tangibles/TangibleStaticMesh.uasset index 36f5827a..15cee6af 100644 --- a/Content/Tangibles/TangibleStaticMesh.uasset +++ b/Content/Tangibles/TangibleStaticMesh.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0e526331f96e31ec6b8b3bb3f3bbc9ce5673f0a29c46a3765dff56814645ca1e -size 324848 +oid sha256:99fda10417bc30a55d5e74ceffa8da3d457636154e4dba697d64fe5c6de96cd9 +size 272097 diff --git a/Integration.uproject b/Integration.uproject index 26802a9c..837eaf87 100644 --- a/Integration.uproject +++ b/Integration.uproject @@ -1,6 +1,6 @@ { "FileVersion": 3, - "EngineAssociation": "5.2", + "EngineAssociation": "7FEDF449-AA25-4EAD-95E8-57052240796D", "Category": "", "Description": "", "Modules": [ diff --git a/Source/Integration/AnimQueue.h b/Source/Integration/AnimQueue.h index 9a7f8012..ea85ee7e 100644 --- a/Source/Integration/AnimQueue.h +++ b/Source/Integration/AnimQueue.h @@ -92,7 +92,7 @@ class INTEGRATION_API UlxAnimationStepLibrary : public UObject GENERATED_BODY() public: - UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex) + UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Luprex") static FString AnimationStepDebugString(const FlxAnimationStep& step); UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "into"), Category = Luprex) diff --git a/Source/Integration/IntegrationGameModeBase.cpp b/Source/Integration/IntegrationGameModeBase.cpp index 09a153ee..d32555d6 100644 --- a/Source/Integration/IntegrationGameModeBase.cpp +++ b/Source/Integration/IntegrationGameModeBase.cpp @@ -6,7 +6,6 @@ #include "DebugPrint.h" #include "Tangible.h" #include "TangibleManager.h" -#include "LookAtDetector.h" #include "CommonTypes.h" #include "AnimQueue.h" #include @@ -84,8 +83,9 @@ void AIntegrationGameModeBase::ResetToInitialState() // Clear the PlayerID PlayerId = 0; - // Clear the actor selector; - LookAtDetector = nullptr; + // Clear the look-at state; + PreviousLookAt = nullptr; + CurrentLookAt = nullptr; // Reset the clocks. EngineSeconds = 0.0; @@ -225,7 +225,7 @@ void AIntegrationGameModeBase::OnWorldPreActorTick(UWorld* InWorld, ELevelTick I UpdateConsoleOutput(); UpdateTangibles(); UpdatePossessedTangible(); - if (LookAtDetector != nullptr) LookAtDetector->Update(); + UpdateLookAt(); } } @@ -330,40 +330,22 @@ AIntegrationGameModeBase *AIntegrationGameModeBase::GetFromContext(UObject *cont return GetFromWorld(context->GetWorld()); } -void AIntegrationGameModeBase::SetLookAtDetector(UlxLookAtActorBase *selector) { - LookAtDetector = selector; +void AIntegrationGameModeBase::UpdateLookAt() { + // Rotate the variables. + PreviousLookAt = CurrentLookAt; + CurrentLookAt = nullptr; + + // Make sure the world is fully configured before we attempt to cast rays. + UlxTangible *possessed = TangibleManager->GetPossessedTangible(); + if (possessed == nullptr) return; + APlayerController *pc = GetWorld()->GetFirstPlayerController(); + if (pc == nullptr) return; + APawn *pawn = pc->GetPawn(); + if (pawn == nullptr) return; + if (possessed->GetActor() != pawn) return; + APlayerCameraManager *cam = pc->PlayerCameraManager; + if (cam == nullptr) return; + + CalculateLookAt(pawn, pc, cam); } - - // /** Gets the game mode that owns this component, this will always return null on the client */ - // template - // T* GetGameMode() const - // { - // // Note: Intentionally getting the game mode from the world instead of the game state as it can be null during game state initialization - // static_assert(TPointerIsConvertibleFromTo::Value, "'T' template parameter to GetGameMode must be derived from AGameModeBase"); - // const UWorld* World = GetWorld(); - // return World ? World->GetAuthGameMode() : nullptr; - // } - - - // // in GameplayStatics - // /** Returns the current GameModeBase or Null if it can't be retrieved, such as on the client */ - // UFUNCTION(BlueprintPure, Category="Game", meta=(WorldContext="WorldContextObject")) - // static ENGINE_API class AGameModeBase* GetGameMode(const UObject* WorldContextObject); - - // // Give the URL a chance to override it - // if (AGameModeBase* GameModeBase = GetGameMode()) - // { - // EffectiveBotCount = UGameplayStatics::GetIntOption(GameModeBase->OptionsString, TEXT("NumBots"), EffectiveBotCount); - // } - - // // In UWorld - // /** - // * Returns the current Game Mode instance cast to the template type. - // * This can only return a valid pointer on the server and may be null if the cast fails. Will always return null on a client. - // */ - // template< class T > - // T* GetAuthGameMode() const - // { - // return Cast(AuthorityGameMode); - // } diff --git a/Source/Integration/IntegrationGameModeBase.h b/Source/Integration/IntegrationGameModeBase.h index 8b0820d6..cb714d48 100644 --- a/Source/Integration/IntegrationGameModeBase.h +++ b/Source/Integration/IntegrationGameModeBase.h @@ -46,7 +46,16 @@ public: int64 GetPlayerId(); UFUNCTION(BlueprintCallable, Category = "Luprex") - void SetLookAtDetector(UlxLookAtActorBase *det); + void SetLookAt(AActor *actor) { CurrentLookAt = actor; } + + UFUNCTION(BlueprintCallable, Category = "Luprex") + AActor *GetLookAt() const { return CurrentLookAt; } + + UFUNCTION(BlueprintCallable, Category = "Luprex") + bool LookAtChanged() const { return CurrentLookAt != PreviousLookAt; } + + UFUNCTION(BlueprintImplementableEvent, Category = "Luprex") + void CalculateLookAt(AActor *Player, APlayerController *PlayerController, APlayerCameraManager *Camera); // Assemble a lua call. To call into lua: // @@ -81,6 +90,10 @@ public: // Maybe call 'BecomePossessed' on the player tangible. void UpdatePossessedTangible(); + // Call 'CalculateLookAt', but only if everything is valid. + // It is up to the blueprint code to actually determine what we're looking at. + void UpdateLookAt(); + // Pre-tick and post-tick functions. void OnWorldPreActorTick(UWorld* InWorld, ELevelTick InLevelTick, float InDeltaSeconds); void OnWorldPostActorTick(UWorld* InWorld, ELevelTick InLevelTick, float InDeltaSeconds); @@ -97,8 +110,13 @@ public: UPROPERTY() UlxTangibleManager *TangibleManager; + // The actor that the player is looking at, previous frame. UPROPERTY() - UlxLookAtActorBase *LookAtDetector; + AActor *PreviousLookAt; + + // The actor that the player is looking at, current frame. + UPROPERTY() + AActor *CurrentLookAt; // This stores the entire text currently visible in the console. FlxConsoleOutput ConsoleOutput; diff --git a/Source/Integration/LookAtDetector.cpp b/Source/Integration/LookAtDetector.cpp deleted file mode 100644 index bea7cc33..00000000 --- a/Source/Integration/LookAtDetector.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - - -#include "LookAtDetector.h" -#include "IntegrationGameModeBase.h" - - -UlxLookAtActorBase::UlxLookAtActorBase() { - GameMode = nullptr; - Player = nullptr; - PlayerController = nullptr; - CameraManager = nullptr; - PreviousSelectedActor = nullptr; - CurrentSelectedActor = nullptr; -} - -void UlxLookAtActorBase::Update() { - GameMode = nullptr; - Player = nullptr; - PlayerController = nullptr; - CameraManager = nullptr; - PreviousSelectedActor = CurrentSelectedActor; - CurrentSelectedActor = nullptr; - - // Make sure the world is fully configured before we attempt to cast rays. - AIntegrationGameModeBase *gm = AIntegrationGameModeBase::GetFromWorld(GetWorld()); - if (gm == nullptr) return; - UlxTangible *possessed = gm->TangibleManager->GetPossessedTangible(); - if (possessed == nullptr) return; - APlayerController *pc = GetWorld()->GetFirstPlayerController(); - if (pc == nullptr) return; - APawn *pawn = pc->GetPawn(); - if (pawn == nullptr) return; - APlayerCameraManager *cam = pc->PlayerCameraManager; - if (cam == nullptr) return; - - GameMode = gm; - Player = pawn; - PlayerController = pc; - CameraManager = cam; - - Recalculate(); -} - -// void AIntegrationGameModeBase::CastCameraRay() { -// // The range we're using is currently hardwired. -// double range = 1000.0; - -// // Get the ray in question. -// APlayerCameraManager *camManager = GetWorld()->GetFirstPlayerController()->PlayerCameraManager; -// FVector TraceStart = camManager->GetCameraLocation(); -// FVector TraceVector = camManager->GetCameraRotation().Vector(); -// FVector TraceEnd = TraceStart + (TraceVector * range); - -// // FHitResult will hold all data returned by our line collision query -// FHitResult Hit; - -// // You can use FCollisionQueryParams to further configure the query -// // Here we add ourselves to the ignored list so we won't block the trace -// FCollisionQueryParams QueryParams; -// QueryParams.AddIgnoredActor(possessed->GetActor()); - -// // To run the query, you need a pointer to the current level, which you can get from an Actor with GetWorld() -// // UWorld()->LineTraceSingleByChannel runs a line trace and returns the first actor hit over the provided collision channel. -// GetWorld()->LineTraceSingleByChannel(Hit, TraceStart, TraceEnd, ECC_Visibility, QueryParams); - -// // You can use DrawDebug helpers and the log to help visualize and debug your trace queries. -// // DrawDebugLine(GetWorld(), TraceStart, TraceEnd, Hit.bBlockingHit ? FColor::Blue : FColor::Red, false, 2.0f, 0, 5.0f); -// // UE_LOG(LogTemp, Log, TEXT("Tracing line: %s to %s"), *TraceStart.ToCompactString(), *TraceVector.ToCompactString()); - -// // If the trace hit something, bBlockingHit will be true, -// // and its fields will be filled with detailed info about what was hit -// if (Hit.bBlockingHit && IsValid(Hit.GetActor())) { -// CameraRayChanged = (CameraRayTarget != Hit.GetActor()); -// CameraRayTarget = Hit.GetActor(); -// } else { -// CameraRayChanged = (CameraRayTarget != nullptr); -// CameraRayTarget = nullptr; -// } -// } - diff --git a/Source/Integration/LookAtDetector.h b/Source/Integration/LookAtDetector.h deleted file mode 100644 index 3bf99837..00000000 --- a/Source/Integration/LookAtDetector.h +++ /dev/null @@ -1,67 +0,0 @@ -// Fill out your copyright notice in the Description page of Project Settings. - -#pragma once - -#include "CoreMinimal.h" -#include "Runtime/Engine/Classes/GameFramework/PlayerController.h" -#include "LookAtDetector.generated.h" - -class AIntegrationGameModeBase; - -/** - * - */ -UCLASS() -class INTEGRATION_API UlxLookAtActorBase : public UObject -{ - GENERATED_BODY() - -public: - UlxLookAtActorBase(); - ~UlxLookAtActorBase() {}; - - // Used by the IntegrationGameModeBase to trigger recalculation. - UFUNCTION(BlueprintCallable, Category = "Luprex") - void Update(); - - // Used in blueprints to set the result object. - UFUNCTION(BlueprintCallable, Category = "Luprex") - void SetSelectedActor(AActor *actor) { CurrentSelectedActor = actor; } - - // Used to find out if the selection recently changed. - UFUNCTION(BlueprintCallable, Category = "Luprex") - bool SelectionChanged() { return (PreviousSelectedActor != CurrentSelectedActor); } - - // Defined in blueprints to do the actual recalculation. - UFUNCTION(BlueprintImplementableEvent, Category = "Luprex") - void Recalculate(); - -public: - - -public: - // A pointer to an IntegrationGameModeBase. - UPROPERTY(BlueprintReadOnly) - AIntegrationGameModeBase *GameMode; - - // A pointer to an actor, the current character. - UPROPERTY(BlueprintReadOnly) - AActor *Player; - - // A pointer to the player controller. - UPROPERTY(BlueprintReadOnly) - APlayerController *PlayerController; - - // A pointer to the camera manager. - UPROPERTY(BlueprintReadOnly) - APlayerCameraManager *CameraManager; - - // The selected actor on the previous frame. - UPROPERTY(BlueprintReadOnly) - AActor *PreviousSelectedActor; - - // The selected actor on the current frame. - UPROPERTY(BlueprintReadOnly) - AActor *CurrentSelectedActor; - -};