Partway done with refactor to lx Player Controller
This commit is contained in:
BIN
Content/Luprex/lxPlayerController.uasset
LFS
Executable file → Normal file
BIN
Content/Luprex/lxPlayerController.uasset
LFS
Executable file → Normal file
Binary file not shown.
@@ -3,11 +3,11 @@
|
|||||||
"",
|
"",
|
||||||
"The unreal build system generates Integration.code-workspace.",
|
"The unreal build system generates Integration.code-workspace.",
|
||||||
"That generated file is no good. Instead, we generate our own,",
|
"That generated file is no good. Instead, we generate our own,",
|
||||||
"as part of build-everything.py",
|
"as part of build.py",
|
||||||
"",
|
"",
|
||||||
"Don't edit Integration.code-worspace, instead, edit",
|
"Don't edit Integration.code-worspace, instead, edit",
|
||||||
"Integration.code-workspace.tpl.json, and then run",
|
"Integration.code-workspace.tpl.json, and then run",
|
||||||
"build-everything.py to rebuild.",
|
"build.py code-workspace to rebuild.",
|
||||||
""
|
""
|
||||||
],
|
],
|
||||||
"folders": [
|
"folders": [
|
||||||
@@ -65,7 +65,6 @@
|
|||||||
"vadimcn.vscode-lldb",
|
"vadimcn.vscode-lldb",
|
||||||
"dfarley1.file-picker",
|
"dfarley1.file-picker",
|
||||||
"ms-python.python",
|
"ms-python.python",
|
||||||
"ms-dotnettools.csharp",
|
|
||||||
"ms-vscode.mono-debug"
|
"ms-vscode.mono-debug"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -88,15 +87,6 @@
|
|||||||
"clear": true
|
"clear": true
|
||||||
},
|
},
|
||||||
"problemMatcher": [
|
"problemMatcher": [
|
||||||
{
|
|
||||||
"owner": "build-luprex",
|
|
||||||
"source": "build.py",
|
|
||||||
"fileLocation": ["relative", "${workspaceFolder}/luprex"],
|
|
||||||
"pattern": {
|
|
||||||
"regexp": "^(.*):(\\d+):(\\d+):\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
|
||||||
"file": 1, "line": 2, "column": 3, "severity": 4, "message": 5
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"owner": "build-integration",
|
"owner": "build-integration",
|
||||||
"source": "build.py",
|
"source": "build.py",
|
||||||
@@ -137,6 +127,7 @@
|
|||||||
"initCommands": [
|
"initCommands": [
|
||||||
"command script import [UNREALENGINE]/Engine/Extras/LLDBDataFormatters/UEDataFormatters_2ByteChars.py",
|
"command script import [UNREALENGINE]/Engine/Extras/LLDBDataFormatters/UEDataFormatters_2ByteChars.py",
|
||||||
"settings set target.inline-breakpoint-strategy always",
|
"settings set target.inline-breakpoint-strategy always",
|
||||||
|
"process handle SIGTRAP --notify false --pass false --stop false",
|
||||||
"target stop-hook add --one-liner \"p ::UngrabAllInputImpl()\""
|
"target stop-hook add --one-liner \"p ::UngrabAllInputImpl()\""
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
#include "LuprexGameModeBase.h"
|
#include "LuprexGameModeBase.h"
|
||||||
|
#include "PlayerControllerBase.h"
|
||||||
#include "LockedWrapper.h"
|
#include "LockedWrapper.h"
|
||||||
#include "lpx-drvutil.hpp"
|
#include "lpx-drvutil.hpp"
|
||||||
#include "Misc/Paths.h"
|
#include "Misc/Paths.h"
|
||||||
@@ -56,10 +57,6 @@ void ALuprexGameModeBase::ResetToInitialState()
|
|||||||
// Clear the PlayerID
|
// Clear the PlayerID
|
||||||
PlayerId = 0;
|
PlayerId = 0;
|
||||||
|
|
||||||
// Clear the look-at state;
|
|
||||||
CurrentLookAt.Init();
|
|
||||||
MustCallLookAtChanged = false;
|
|
||||||
|
|
||||||
// Reset the clocks.
|
// Reset the clocks.
|
||||||
EngineSeconds = 0.0;
|
EngineSeconds = 0.0;
|
||||||
}
|
}
|
||||||
@@ -171,7 +168,8 @@ void ALuprexGameModeBase::OnWorldPostActorTick(UWorld* InWorld, ELevelTick InLev
|
|||||||
UpdateConsoleOutput();
|
UpdateConsoleOutput();
|
||||||
UpdateTangibles();
|
UpdateTangibles();
|
||||||
UpdatePossessedTangible();
|
UpdatePossessedTangible();
|
||||||
UpdateLookAt();
|
AlxPlayerControllerBase *PC = Cast<AlxPlayerControllerBase>(GetWorld()->GetFirstPlayerController());
|
||||||
|
if (PC != nullptr) PC->UpdateLookAt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,52 +256,3 @@ ALuprexGameModeBase *ALuprexGameModeBase::FromContext(const UObject *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ALuprexGameModeBase::SetLookAt(const UObject *Context, const FHitResult &HitResult)
|
|
||||||
{
|
|
||||||
ALuprexGameModeBase *Mode = FromContext(Context);
|
|
||||||
if (Mode->CurrentLookAt.HitObjectHandle != HitResult.HitObjectHandle)
|
|
||||||
{
|
|
||||||
Mode->MustCallLookAtChanged = true;
|
|
||||||
}
|
|
||||||
Mode->CurrentLookAt = HitResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ALuprexGameModeBase::SetLookAtChanged(const UObject *Context)
|
|
||||||
{
|
|
||||||
ALuprexGameModeBase *Mode = FromContext(Context);
|
|
||||||
Mode->MustCallLookAtChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
FVector2D ALuprexGameModeBase::GetLookAtPixel(const UObject *Context)
|
|
||||||
{
|
|
||||||
ALuprexGameModeBase *Mode = FromContext(Context);
|
|
||||||
APlayerController *pc = Context->GetWorld()->GetFirstPlayerController();
|
|
||||||
if (pc == nullptr) return FVector2D();
|
|
||||||
FVector2D ScreenPosition;
|
|
||||||
if (!UGameplayStatics::ProjectWorldToScreen(pc, Mode->CurrentLookAt.Location, ScreenPosition, false))
|
|
||||||
{
|
|
||||||
return FVector2D();
|
|
||||||
}
|
|
||||||
return ScreenPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ALuprexGameModeBase::UpdateLookAt() {
|
|
||||||
// Make sure the world is fully configured before we attempt to cast rays.
|
|
||||||
UlxTangible *possessed = GetGameInstance()->GetSubsystem<UlxTangibleManager>()->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(pc);
|
|
||||||
|
|
||||||
if (MustCallLookAtChanged) {
|
|
||||||
MustCallLookAtChanged = false;
|
|
||||||
LookAtChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Engine/HitResult.h"
|
|
||||||
#include "GameFramework/GameModeBase.h"
|
#include "GameFramework/GameModeBase.h"
|
||||||
#include "LuprexSockets.h"
|
#include "LuprexSockets.h"
|
||||||
#include "BreakToDebugger.h"
|
#include "BreakToDebugger.h"
|
||||||
@@ -37,32 +36,6 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "Luprex|Miscellaneous")
|
UFUNCTION(BlueprintCallable, Category = "Luprex|Miscellaneous")
|
||||||
int64 GetPlayerId();
|
int64 GetPlayerId();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
|
||||||
static void SetLookAt(const UObject *Context, const FHitResult &HitResult);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"),Category = "Luprex|Look-At Detection")
|
|
||||||
static const FHitResult &GetLookAt(const UObject *Context) { return FromContext(Context)->CurrentLookAt; }
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"),Category = "Luprex|Look-At Detection")
|
|
||||||
static const AActor *GetLookAtActor(const UObject *Context) { return FromContext(Context)->CurrentLookAt.GetActor(); }
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"),Category = "Luprex|Look-At Detection")
|
|
||||||
static FVector2D GetLookAtPixel(const UObject *Context);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
|
||||||
static void SetLookAtChanged(const UObject* Context);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Look-At Related Events
|
|
||||||
//
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
|
|
||||||
void CalculateLookAt(APlayerController *PlayerController);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
|
|
||||||
void LookAtChanged();
|
|
||||||
|
|
||||||
|
|
||||||
// Transfer console output from the Luprex engine to unreal.
|
// Transfer console output from the Luprex engine to unreal.
|
||||||
void UpdateConsoleOutput();
|
void UpdateConsoleOutput();
|
||||||
|
|
||||||
@@ -75,10 +48,6 @@ public:
|
|||||||
// Tell the player controller to possess that tangible.
|
// Tell the player controller to possess that tangible.
|
||||||
void UpdatePossessedTangible();
|
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();
|
|
||||||
|
|
||||||
// If the engine wants a new copy of the lua source code,
|
// If the engine wants a new copy of the lua source code,
|
||||||
// provide it.
|
// provide it.
|
||||||
void UpdateLuaSourceCode();
|
void UpdateLuaSourceCode();
|
||||||
@@ -94,12 +63,6 @@ public:
|
|||||||
// Get the current Luprex Game Mode Base, given a Context object.
|
// Get the current Luprex Game Mode Base, given a Context object.
|
||||||
static ALuprexGameModeBase *FromContext(const UObject *Context);
|
static ALuprexGameModeBase *FromContext(const UObject *Context);
|
||||||
|
|
||||||
// The actor that the player is looking at, current frame.
|
|
||||||
UPROPERTY()
|
|
||||||
FHitResult CurrentLookAt;
|
|
||||||
|
|
||||||
bool MustCallLookAtChanged = false;
|
|
||||||
|
|
||||||
// The sensitivity level at which a log message triggers a debugger breakpoint.
|
// The sensitivity level at which a log message triggers a debugger breakpoint.
|
||||||
UPROPERTY(EditAnywhere, Category="Debugging Tools")
|
UPROPERTY(EditAnywhere, Category="Debugging Tools")
|
||||||
ElxBreakToDebuggerThreshold BreakToDebuggerLogVerbosity;
|
ElxBreakToDebuggerThreshold BreakToDebuggerLogVerbosity;
|
||||||
|
|||||||
74
Source/Integration/PlayerControllerBase.cpp
Normal file
74
Source/Integration/PlayerControllerBase.cpp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#include "PlayerControllerBase.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include "Tangible.h"
|
||||||
|
#include "TangibleManager.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
#include "Engine/GameInstance.h"
|
||||||
|
|
||||||
|
AlxPlayerControllerBase *AlxPlayerControllerBase::FromContext(const UObject *Context)
|
||||||
|
{
|
||||||
|
APlayerController *PC = Context->GetWorld()->GetFirstPlayerController();
|
||||||
|
AlxPlayerControllerBase *Result = Cast<AlxPlayerControllerBase>(PC);
|
||||||
|
if (Result == nullptr)
|
||||||
|
{
|
||||||
|
UE_LOG(LogLuprexIntegration, Fatal, TEXT("Not currently using a Luprex Player Controller."));
|
||||||
|
}
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FHitResult &AlxPlayerControllerBase::GetLookAt(const UObject *Context)
|
||||||
|
{
|
||||||
|
return FromContext(Context)->CurrentLookAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AActor *AlxPlayerControllerBase::GetLookAtActor(const UObject *Context)
|
||||||
|
{
|
||||||
|
return FromContext(Context)->CurrentLookAt.GetActor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlxPlayerControllerBase::SetLookAt(const UObject *Context, const FHitResult &HitResult)
|
||||||
|
{
|
||||||
|
AlxPlayerControllerBase *PC = FromContext(Context);
|
||||||
|
if (PC->CurrentLookAt.HitObjectHandle != HitResult.HitObjectHandle)
|
||||||
|
{
|
||||||
|
PC->MustCallLookAtChanged = true;
|
||||||
|
}
|
||||||
|
PC->CurrentLookAt = HitResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlxPlayerControllerBase::SetLookAtChanged(const UObject *Context)
|
||||||
|
{
|
||||||
|
AlxPlayerControllerBase *PC = FromContext(Context);
|
||||||
|
PC->MustCallLookAtChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2D AlxPlayerControllerBase::GetLookAtPixel(const UObject *Context)
|
||||||
|
{
|
||||||
|
AlxPlayerControllerBase *PC = FromContext(Context);
|
||||||
|
FVector2D ScreenPosition;
|
||||||
|
if (!UGameplayStatics::ProjectWorldToScreen(PC, PC->CurrentLookAt.Location, ScreenPosition, false))
|
||||||
|
{
|
||||||
|
return FVector2D();
|
||||||
|
}
|
||||||
|
return ScreenPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlxPlayerControllerBase::UpdateLookAt()
|
||||||
|
{
|
||||||
|
UlxTangibleManager *TM = GetGameInstance()->GetSubsystem<UlxTangibleManager>();
|
||||||
|
if (TM == nullptr) return;
|
||||||
|
UlxTangible *Possessed = TM->GetPossessedTangible();
|
||||||
|
if (Possessed == nullptr) return;
|
||||||
|
APawn *Pawn = GetPawn();
|
||||||
|
if (Pawn == nullptr) return;
|
||||||
|
if (Possessed->GetActor() != Pawn) return;
|
||||||
|
if (PlayerCameraManager == nullptr) return;
|
||||||
|
|
||||||
|
CalculateLookAt();
|
||||||
|
|
||||||
|
if (MustCallLookAtChanged)
|
||||||
|
{
|
||||||
|
MustCallLookAtChanged = false;
|
||||||
|
LookAtChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
46
Source/Integration/PlayerControllerBase.h
Normal file
46
Source/Integration/PlayerControllerBase.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Engine/HitResult.h"
|
||||||
|
#include "GameFramework/PlayerController.h"
|
||||||
|
#include "PlayerControllerBase.generated.h"
|
||||||
|
|
||||||
|
UCLASS(BlueprintType, Blueprintable)
|
||||||
|
class INTEGRATION_API AlxPlayerControllerBase : public APlayerController
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
||||||
|
static void SetLookAt(const UObject *Context, const FHitResult &HitResult);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
||||||
|
static const FHitResult &GetLookAt(const UObject *Context);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
||||||
|
static const AActor *GetLookAtActor(const UObject *Context);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
||||||
|
static FVector2D GetLookAtPixel(const UObject *Context);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, meta = (WorldContext = "Context"), Category = "Luprex|Look-At Detection")
|
||||||
|
static void SetLookAtChanged(const UObject *Context);
|
||||||
|
|
||||||
|
// Blueprint events
|
||||||
|
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
|
||||||
|
void CalculateLookAt();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintImplementableEvent, Category = "Luprex|Look-At Detection")
|
||||||
|
void LookAtChanged();
|
||||||
|
|
||||||
|
// Called by GameMode each tick.
|
||||||
|
void UpdateLookAt();
|
||||||
|
|
||||||
|
// Get the player controller, cast to AlxPlayerControllerBase.
|
||||||
|
static AlxPlayerControllerBase *FromContext(const UObject *Context);
|
||||||
|
|
||||||
|
UPROPERTY()
|
||||||
|
FHitResult CurrentLookAt;
|
||||||
|
|
||||||
|
bool MustCallLookAtChanged = false;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user