OLS/Source/ols/Private/Camera/OLSPlayerCameraManager.cpp
LongLy 57b53b9c0c Implemented OLSCameraMode.
Addressed @TODOs related to custom logs and OLSCameraMode
2025-01-20 14:08:07 -07:00

62 lines
2.0 KiB
C++

// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.
#include "Camera/OLSPlayerCameraManager.h"
#include "Camera/Components/OLSCameraComponent.h"
#include "Camera/Components/OLSUICameraManagerComponent.h"
#include "Engine/Canvas.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(OLSPlayerCameraManager)
static FName UICameraComponentName(TEXT("UICameraComponent"));
AOLSPlayerCameraManager::AOLSPlayerCameraManager(const FObjectInitializer& objectInitializer)
: Super(objectInitializer)
{
DefaultFOV = OLS_CAMERA_DEFAULT_FOV;
ViewPitchMin = OLS_CAMERA_DEFAULT_PITCH_MIN;
ViewPitchMax = OLS_CAMERA_DEFAULT_PITCH_MAX;
UICameraComponent = CreateDefaultSubobject<UOLSUICameraManagerComponent>(UICameraComponentName);
}
UOLSUICameraManagerComponent* AOLSPlayerCameraManager::GetUICameraComponent() const
{
return UICameraComponent;
}
void AOLSPlayerCameraManager::UpdateViewTarget(FTViewTarget& outVT, float deltaTime)
{
// If the UI Camera is looking at something, let it have priority.
if (UICameraComponent->NeedsToUpdateViewTarget())
{
Super::UpdateViewTarget(outVT, deltaTime);
UICameraComponent->UpdateViewTarget(outVT, deltaTime);
return;
}
Super::UpdateViewTarget(outVT, deltaTime);
}
void AOLSPlayerCameraManager::DisplayDebug(UCanvas* canvas, const FDebugDisplayInfo& debugDisplay,
float& yl, float& yPos)
{
check(canvas);
FDisplayDebugManager& displayDebugManager = canvas->DisplayDebugManager;
displayDebugManager.SetFont(GEngine->GetSmallFont());
displayDebugManager.SetDrawColor(FColor::Yellow);
displayDebugManager.DrawString(FString::Printf(TEXT("LyraPlayerCameraManager: %s"), *GetNameSafe(this)));
Super::DisplayDebug(canvas, debugDisplay, yl, yPos);
const APawn* pawn = (PCOwner ? PCOwner->GetPawn() : nullptr);
if (const UOLSCameraComponent* cameraComponent = UOLSCameraComponent::FindCameraComponent(pawn))
{
cameraComponent->DrawDebug(canvas);
}
}