File size: 2,037 Bytes
3243e23 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | // Copyright Epic Games, Inc. All Rights Reserved.
#include "CommonLocalPlayer.h"
#include "Engine/GameInstance.h"
#include "GameFramework/PlayerController.h"
#include "GameUIManagerSubsystem.h"
#include "GameUIPolicy.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(CommonLocalPlayer)
class APawn;
class APlayerState;
class FViewport;
struct FSceneViewProjectionData;
UCommonLocalPlayer::UCommonLocalPlayer()
: Super(FObjectInitializer::Get())
{
}
FDelegateHandle UCommonLocalPlayer::CallAndRegister_OnPlayerControllerSet(FPlayerControllerSetDelegate::FDelegate Delegate)
{
APlayerController* PC = GetPlayerController(GetWorld());
if (PC)
{
Delegate.Execute(this, PC);
}
return OnPlayerControllerSet.Add(Delegate);
}
FDelegateHandle UCommonLocalPlayer::CallAndRegister_OnPlayerStateSet(FPlayerStateSetDelegate::FDelegate Delegate)
{
APlayerController* PC = GetPlayerController(GetWorld());
APlayerState* PlayerState = PC ? PC->PlayerState : nullptr;
if (PlayerState)
{
Delegate.Execute(this, PlayerState);
}
return OnPlayerStateSet.Add(Delegate);
}
FDelegateHandle UCommonLocalPlayer::CallAndRegister_OnPlayerPawnSet(FPlayerPawnSetDelegate::FDelegate Delegate)
{
APlayerController* PC = GetPlayerController(GetWorld());
APawn* Pawn = PC ? PC->GetPawn() : nullptr;
if (Pawn)
{
Delegate.Execute(this, Pawn);
}
return OnPlayerPawnSet.Add(Delegate);
}
bool UCommonLocalPlayer::GetProjectionData(FViewport* Viewport, FSceneViewProjectionData& ProjectionData, int32 StereoViewIndex) const
{
if (!bIsPlayerViewEnabled)
{
return false;
}
return Super::GetProjectionData(Viewport, ProjectionData, StereoViewIndex);
}
UPrimaryGameLayout* UCommonLocalPlayer::GetRootUILayout() const
{
if (UGameUIManagerSubsystem* UIManager = GetGameInstance()->GetSubsystem<UGameUIManagerSubsystem>())
{
if (UGameUIPolicy* Policy = UIManager->GetCurrentUIPolicy())
{
return Policy->GetRootLayout(this);
}
}
return nullptr;
}
|