Partway done with refactor to lx Player Controller
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "LuprexGameModeBase.h"
|
||||
#include "PlayerControllerBase.h"
|
||||
#include "LockedWrapper.h"
|
||||
#include "lpx-drvutil.hpp"
|
||||
#include "Misc/Paths.h"
|
||||
@@ -56,10 +57,6 @@ void ALuprexGameModeBase::ResetToInitialState()
|
||||
// Clear the PlayerID
|
||||
PlayerId = 0;
|
||||
|
||||
// Clear the look-at state;
|
||||
CurrentLookAt.Init();
|
||||
MustCallLookAtChanged = false;
|
||||
|
||||
// Reset the clocks.
|
||||
EngineSeconds = 0.0;
|
||||
}
|
||||
@@ -171,7 +168,8 @@ void ALuprexGameModeBase::OnWorldPostActorTick(UWorld* InWorld, ELevelTick InLev
|
||||
UpdateConsoleOutput();
|
||||
UpdateTangibles();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user